Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. internal abstract class ViewModel : IViewModel
  2. {
  3. private readonly AutoResetEvent autoResetEvent = new AutoResetEvent(true);
  4.  
  5. protected Task SynchronousTask(IList<Action> actions)
  6. {
  7. var initialTask = new Task(() => this.autoResetEvent.WaitOne());
  8.  
  9. for (var i = 0; i < actions.Count; i++)
  10. {
  11. var i1 = i;
  12. initialTask.ContinueWith(task => actions[i1]());
  13. }
  14.  
  15. initialTask.ContinueWith(task => this.autoResetEvent.Set());
  16.  
  17. initialTask.Start();
  18. return initialTask;
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement