SynchronizationContext 類別

定義

提供在各種同步處理模式中散佈同步處理內容的基本功能。Provides the basic functionality for propagating a synchronization context in various synchronization models.

public ref class SynchronizationContext
public class SynchronizationContext
type SynchronizationContext = class
Public Class SynchronizationContext
繼承
SynchronizationContext
衍生

備註

SynchronizationContext類別是一種基類, 可提供沒有同步處理的無限制執行緒內容。The SynchronizationContext class is a base class that provides a free-threaded context with no synchronization.

這個類別所實作為同步處理模型的目的, 是為了讓 common language runtime 的內部非同步/同步作業能夠以不同的同步模型正確運作。The purpose of the synchronization model implemented by this class is to allow the internal asynchronous/synchronous operations of the common language runtime to behave properly with different synchronization models. 此模型也會簡化 managed 應用程式必須遵循的一些需求, 才能在不同的同步處理環境下正常運作。This model also simplifies some of the requirements that managed applications have had to follow in order to work correctly under different synchronization environments.

同步處理模型的提供者可以擴充這個類別, 並為這些方法提供自己的執行。Providers of synchronization models can extend this class and provide their own implementations for these methods.

如需有關同步處理內容的詳細資訊, 請參閱 MSDN 雜誌中的SynchronizationCoNtext 的相關文章。For more information about synchronization contexts, see the article It's All About the SynchronizationContext in the MSDN Magazine.

建構函式

SynchronizationContext()

建立 SynchronizationContext 類別的新執行個體。Creates a new instance of the SynchronizationContext class.

屬性

Current

取得目前執行緒的同步處理內容。Gets the synchronization context for the current thread.

方法

CreateCopy()

在衍生類別中覆寫時,會建立同步處理內容的複本。When overridden in a derived class, creates a copy of the synchronization context.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IsWaitNotificationRequired()

判斷是否需要等候告知。Determines if wait notification is required.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
OperationCompleted()

在衍生類別中覆寫時,會回應作業已經完成的通知。When overridden in a derived class, responds to the notification that an operation has completed.

OperationStarted()

在衍生類別中覆寫時,會回應作業已經啟動的通知。When overridden in a derived class, responds to the notification that an operation has started.

Post(SendOrPostCallback, Object)

在衍生類別中覆寫時,會將非同步訊息分派至同步處理內容。When overridden in a derived class, dispatches an asynchronous message to a synchronization context.

Send(SendOrPostCallback, Object)

在衍生類別中覆寫時,會將同步訊息分派至同步處理內容。When overridden in a derived class, dispatches a synchronous message to a synchronization context.

SetSynchronizationContext(SynchronizationContext)

設定目前的同步處理內容。Sets the current synchronization context.

SetThreadStaticContext(SynchronizationContext)
SetWaitNotificationRequired()

設定告知,表示需要等候告知,並準備回呼 (Callback) 方法,以便在發生等候狀況時,可以順利呼叫該方法。Sets notification that wait notification is required and prepares the callback method so it can be called more reliably when a wait occurs.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
Wait(IntPtr[], Boolean, Int32)

等候指定陣列中的任何元素或所有元素接收信號。Waits for any or all the elements in the specified array to receive a signal.

WaitHelper(IntPtr[], Boolean, Int32)

Helper 函式,等候指定陣列中的任何元素或所有元素接收信號。Helper function that waits for any or all the elements in the specified array to receive a signal.

安全性

InheritanceDemand
繼承者必須ControlPolicy具有ControlEvidence和。Inheritors must have ControlPolicy and ControlEvidence.

適用於