daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Aug 19th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.    });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top