Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WorkloadManager.Instance.Add(Subscriptions.Instance.Dictionary.Count);
- int i = 0;
- var tasks = new Task[Subscriptions.Instance.Dictionary.Count];
- foreach (var pair in this._feeds)
- {
- var feed = pair.Value;
- feed.OnStateChange += UpdateState;
- tasks[i] = Task.Factory.StartNew(() => TaskProcessFeed(feed));
- i++;
- }
- var tasksWaitQueue = tasks;
- while (tasksWaitQueue.Length > 0)
- {
- int taskIndex = Task.WaitAny(tasksWaitQueue);
- tasksWaitQueue = tasksWaitQueue.Where((t) => t != tasksWaitQueue[taskIndex]).ToArray();
- WorkloadManager.Instance.Step();
- }
- try { Task.WaitAll(tasks); }
- catch (AggregateException aggregateException)
- {
- foreach (var exception in aggregateException.InnerExceptions)
- {
- Logger.ErrorException(exception, "One of the tasks failed.");
- }
- }
Add Comment
Please, Sign In to add comment