Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are calling this from within SQL Server?</p> <p>Why not just have the bulk update run in a separate thread, and just return back quickly that it has been queued and is being processed.</p> <p>I have done this to prevent using too many database connections, I just put the data into a queue, and every ten seconds I process whatever is in the queue.</p> <p>Then your second function can check on the status.</p> <p><strong>UPDATE:</strong></p> <p>I have a static class that does the processing, and the code is at the end. Basically, the call comes in and I return immediately that it was successfully put in a queue. The queue just runs in the background, checking every ten seconds and processing whatever is in there.</p> <p>I use a <code>ConcurrentQueue</code> for my queue so that I can write and process at the same time. </p> <p>So, you can use this to start updating, then another call can see how many have been processed and return that information back.</p> <pre><code> public string[] UpdateJobs(Jobs[] jobs) { WebServiceControllerStatic.JobQueue = jobs; WebServiceControllerStatic.ProcessUpdateJobQueue(); List&lt;String&gt; s = new List&lt;String&gt;(); for (int t = 0; t &lt; jobs.Length; t++) { s.Add("Success"); } return s.ToArray(); } </code></pre> <p>These are in WebServiceControllerStatic class:</p> <pre><code> public static Jobs[] JobQueue { set { try { value.AsParallel().ForAll(i =&gt; jobqueue.Enqueue(i)); } catch (Exception e) { writeToLog("..\r\n" + e.Message + "\r\n" + e.StackTrace); } } } public static void ProcessUpdateJobQueue() { Action UpdateJob = () =&gt; { if (jobqueue.IsEmpty) return; Parallel.For(0, jobqueue.Count, new ParallelOptions() { MaxDegreeOfParallelism = 1 }, (j) =&gt; { // Do updates here }); }; if (processUpdateJobThread == null) { processUpdateJobThread = new System.Threading.Thread(() =&gt; { while (true) { UpdateJob(); System.Threading.Thread.Sleep(10000); } }); processUpdateJobThread.Start(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload