Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. public static void WorkUntilFinishedOrCancelled(CancellationToken token, params Action[] work)
  2. {
  3. foreach (var workItem in work)
  4. {
  5. token.ThrowIfCancellationRequested();
  6. workItem();
  7. }
  8. }
  9.  
  10. async Task<Bar> DoWork(Foo foo)
  11. {
  12. WorkUntilFinishedOrCancelled([YourCancellationToken], DoStuff1, DoStuff2, DoStuff3, ...);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement