daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WorkloadManager.Instance.Add(Subscriptions.Instance.Dictionary.Count);
  2.  
  3.             int i = 0;
  4.             var tasks = new Task[Subscriptions.Instance.Dictionary.Count];
  5.  
  6.             foreach (var pair in this._feeds)
  7.             {
  8.                 var feed = pair.Value;
  9.                 feed.OnStateChange += UpdateState;
  10.                 tasks[i] = Task.Factory.StartNew(() => TaskProcessFeed(feed));
  11.                 i++;
  12.             }
  13.  
  14.             var tasksWaitQueue = tasks;
  15.  
  16.             while (tasksWaitQueue.Length > 0)
  17.             {
  18.                 int taskIndex = Task.WaitAny(tasksWaitQueue);
  19.                 tasksWaitQueue = tasksWaitQueue.Where((t) => t != tasksWaitQueue[taskIndex]).ToArray();
  20.                 WorkloadManager.Instance.Step();
  21.             }
  22.  
  23.             try { Task.WaitAll(tasks); }
  24.             catch (AggregateException aggregateException)
  25.             {
  26.                 foreach (var exception in aggregateException.InnerExceptions)
  27.                 {
  28.                     Logger.ErrorException(exception, "One of the tasks failed.");
  29.                 }
  30.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top