Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Am I responsible for cleaning up after a Task created with the TaskCreationOptions.LongRunning flag?
- var task = Task.Factory.StartNew(() => {...}, TaskCreationOptions.LongRunning);
- task.ContinueWith(x => task.Dispose());
- var task = Task.Factory.StartNew(() => {...}, TaskCreationOptions.LongRunning)
- .ContinueWith(x =>
- if(x.IsFaulted)
- {
- x.Exception.Handle(_ => true); //just an example, you'll want to handle properly
- }
- else if(x.IsCompleted)
- {
- //do something with the result, if necessary
- x.Dispose());
- });
Add Comment
Please, Sign In to add comment