HostExecutionContextManager.SetHostExecutionContext(HostExecutionContext) 方法
定义
将当前宿主执行上下文设置为指定的宿主执行上下文。Sets the current host execution context to the specified host execution context.
public:
virtual System::Object ^ SetHostExecutionContext(System::Threading::HostExecutionContext ^ hostExecutionContext);
public virtual object SetHostExecutionContext (System.Threading.HostExecutionContext hostExecutionContext);
[System.Security.SecurityCritical]
public virtual object SetHostExecutionContext (System.Threading.HostExecutionContext hostExecutionContext);
abstract member SetHostExecutionContext : System.Threading.HostExecutionContext -> obj
override this.SetHostExecutionContext : System.Threading.HostExecutionContext -> obj
[<System.Security.SecurityCritical>]
abstract member SetHostExecutionContext : System.Threading.HostExecutionContext -> obj
override this.SetHostExecutionContext : System.Threading.HostExecutionContext -> obj
Public Overridable Function SetHostExecutionContext (hostExecutionContext As HostExecutionContext) As Object
参数
- hostExecutionContext
- HostExecutionContext
要设置的 HostExecutionContext。The HostExecutionContext to be set.
返回
一个对象,用于将 HostExecutionContext 还原为其以前的状态。An object for restoring the HostExecutionContext to its previous state.
- 属性
例外
hostExecutionContext 不是通过捕获操作获取的。hostExecutionContext was not acquired through a capture operation.
- 或 --or-
hostExecutionContext 已作为上一次 SetHostExecutionContext(HostExecutionContext) 方法调用的参数。hostExecutionContext has been the argument to a previous SetHostExecutionContext(HostExecutionContext) method call.
注解
SetHostExecutionContext方法设置当前的宿主执行上下文 HostExecutionContext 。The SetHostExecutionContext method sets the host execution context for the current HostExecutionContext. HostExecutionContext作为另一个方法调用的参数使用的 SetHostExecutionContext 不能作为此方法的参数传入。A HostExecutionContext that has been used as the argument to another SetHostExecutionContext method call cannot be passed in as the parameter for this method. 相反,请使用 HostExecutionContext.CreateCopy 方法创建对象的副本 HostExecutionContext ,然后使用副本设置宿主执行上下文。Instead, use the HostExecutionContext.CreateCopy method to create a copy of a HostExecutionContext object and then use the copy to set the host execution context.
Revert使用此方法返回的对象调用方法,将还原 HostExecutionContext 到其以前的状态。Call the Revert method using the object returned by this method to restore the HostExecutionContext to its previous state.