Прочетете на английски Редактиране

Споделяне чрез


HostExecutionContext.Dispose Method

Definition

Releases resources used by the current instance of the HostExecutionContext class.

Overloads

Dispose()

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

Dispose(Boolean)

When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

Dispose()

Source:
HostExecutionContext.cs
Source:
HostExecutionContext.cs
Source:
HostExecutionContext.cs

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

C#
public void Dispose();

Implements

Remarks

Call Dispose when you are finished using the HostExecutionContext. The Dispose method leaves the HostExecutionContext in an unusable state. After calling Dispose, you must release all references to the HostExecutionContext so the garbage collector can reclaim the memory that the HostExecutionContext 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 HostExecutionContext. Otherwise, the resources it is using will not be freed until the garbage collector calls the HostExecutionContext object's Finalize method.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Dispose(Boolean)

Source:
HostExecutionContext.cs
Source:
HostExecutionContext.cs
Source:
HostExecutionContext.cs

When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

C#
public virtual void Dispose(bool disposing);

Parameters

disposing
Boolean

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

This method is called by the Dispose() method overload and the finalizer. Dispose() invokes this protected method with the disposing parameter set to true. The finalizer invokes this method with disposing set to false.

When the disposing parameter is true, this method releases all resources held by any managed objects that this HostExecutionContext references. This method invokes the Dispose method of each referenced object.

This method can be called multiple times by other objects. When overriding this method, be careful not to reference objects that have been previously disposed in an earlier call.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1