Guest User

Untitled

a guest
Aug 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Am I responsible for cleaning up after a Task created with the TaskCreationOptions.LongRunning flag?
  2. var task = Task.Factory.StartNew(() => {...}, TaskCreationOptions.LongRunning);
  3.  
  4. task.ContinueWith(x => task.Dispose());
  5.  
  6. var task = Task.Factory.StartNew(() => {...}, TaskCreationOptions.LongRunning)
  7. .ContinueWith(x =>
  8. if(x.IsFaulted)
  9. {
  10. x.Exception.Handle(_ => true); //just an example, you'll want to handle properly
  11. }
  12. else if(x.IsCompleted)
  13. {
  14. //do something with the result, if necessary
  15. x.Dispose());
  16. });
Add Comment
Please, Sign In to add comment