Task.Dispose Task.Dispose Task.Dispose Task.Dispose Method

Definition

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

Overloads

Dispose() Dispose() Dispose() Dispose()

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

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Disposes the Task, releasing all of its unmanaged resources.

Dispose() Dispose() Dispose() Dispose()

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

public:
 virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()
Implements
Exceptions

Remarks

The Task class implements the IDisposable interface because internally it uses resources that also implement IDisposable. However, particularly if your app targets the .NET Framework 4.5 or later, there is no need to call Dispose unless performance or scalability testing indicates that, based on your usage patterns, your app's performance would be improved by disposing of tasks. For more information, see Do I need to dispose of Tasks? in the Parallel Programming with .NET blog.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Disposes the Task, releasing all of its unmanaged resources.

protected:
 virtual void Dispose(bool disposing);
protected virtual void Dispose (bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
Protected Overridable Sub Dispose (disposing As Boolean)
Parameters
disposing
Boolean Boolean Boolean Boolean

A Boolean value that indicates whether this method is being called due to a call to Dispose().

Exceptions

Remarks

The Task class implements the IDisposable interface because internally it uses resources that also implement IDisposable. However, particularly if your app targets the .NET Framework 4.5 or later, there is no need to call Dispose unless performance or scalability testing indicates that, based on your usage patterns, your app's performance would be improved by disposing of tasks. For more information, see Do I need to dispose of Tasks? in the Parallel Programming with .NET blog.

Applies to