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()




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.


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.


Supported in: 5

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

Community Additions