multithreading - Where should I put "exec this when jobs 1 .. n are done?" -
I have some parallel codes and a thread pool.
And I need to send 15 jobs, and when all 15 are completed , this particular task should be performed "Job 16". You can only complete "Job 16" Jobs 13, 14, 15. Therefore , you should have a way to count. My question is, where is the responsibility related? You can also capture this behavior in your class, and raise an incident when your job is completed to trigger your 16th job queue:
counter ++ When the
counter == 15 , exec job 16
internal class parallelBatchRunner {public event EventHandler full = delegate}; Public Zero Run (list & jobs; task & gt; function) {int count = taskss.Count; Work. Foreike (T => {task completion torque = () => (T); if (interlocked. Acquisition (ref count) == 0} {complete (this, event.rg.pt);}} ; Threadpool QueueUserWorkItem (_ = & gt; Termination Task ());}); }}
Comments
Post a Comment