Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Task.Dispose Method

Releases all resources used by the current instance of the Task class.

Namespace:  System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

public void Dispose()

Implements

IDisposable.Dispose()

ExceptionCondition
InvalidOperationException

The exception that is thrown if the Task is not in one of the final states: RanToCompletion, Faulted, or Canceled.

Call Dispose when you are finished using the Task. The Dispose method leaves the Task in an unusable state. After calling Dispose, you must release all references to the Task so the garbage collector can reclaim the memory that the Task was occupying.

For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.

NoteNote:

Always call Dispose before you release your last reference to the Task. Otherwise, the resources it is using will not be freed until the garbage collector calls the Task object's Finalize method.

Silverlight

Supported in: 5

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft