ExecutionContext.SuppressFlow 方法

定义

取消执行上下文在异步线程之间的流动。Suppresses the flow of the execution context across asynchronous threads.

public:
 static System::Threading::AsyncFlowControl SuppressFlow();
[System.Security.SecurityCritical]
public static System.Threading.AsyncFlowControl SuppressFlow ();
static member SuppressFlow : unit -> System.Threading.AsyncFlowControl
Public Shared Function SuppressFlow () As AsyncFlowControl

返回

用于恢复流动的 AsyncFlowControl 结构。An AsyncFlowControl structure for restoring the flow.

属性

异常

上下文流已取消。The context flow is already suppressed.

注解

使用此方法可取消当前线程上 ExecutionContext 的流动。Use this method to suppress the flow of the ExecutionContext on the current thread.

您必须对返回的 AsyncFlowControl 结构使用 Undo 方法来还原 ExecutionContext流。You must use the Undo method on the returned AsyncFlowControl structure to restore the flow of the ExecutionContext.

此方法使用 SecurityPermissionFlag.Infrastructure 权限的 SecurityAction.LinkDemand 进行保护。This method is protected with a SecurityAction.LinkDemand for SecurityPermissionFlag.Infrastructure permission. 完全受信任的组件可以调用此方法,以在异步调用期间取消 ExecutionContext 的流动。A fully trusted component can call this method to suppress the flow of the ExecutionContext during asynchronous calls. 当流被取消时,Capture 方法返回 nullWhile the flow is suppressed, the Capture method returns null.

安全性

SecurityCriticalAttribute
需要对直接调用方的完全信任。Requires full trust for the immediate caller. 部分受信任的或透明的代码不能使用此成员。This member cannot be used by partially trusted or transparent code.

适用于

另请参阅