System.Threading.HostExecutionContextManager.SetHostExecutionContext Method

Sets the current host execution context to the specified host execution context.

Syntax

public virtual object SetHostExecutionContext (HostExecutionContext hostExecutionContext)

Parameters

hostExecutionContext
The System.Threading.HostExecutionContext to be set.

Returns

An object for restoring the System.Threading.HostExecutionContext to its previous state.

Remarks

The HostExecutionContextManager.SetHostExecutionContext(HostExecutionContext) method sets the host execution context for the current System.Threading.HostExecutionContext. A System.Threading.HostExecutionContext that has been used as the argument to another HostExecutionContextManager.SetHostExecutionContext(HostExecutionContext) method call cannot be passed in as the parameter for this method. Instead, use the HostExecutionContext.CreateCopy method to create a copy of a System.Threading.HostExecutionContext object and then use the copy to set the host execution context.

Call the HostExecutionContextManager.Revert(object) method using the object returned by this method to restore the System.Threading.HostExecutionContext to its previous state.

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0