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.

適用於

另請參閱