SynchronizationContext SynchronizationContext SynchronizationContext SynchronizationContext Class

定义

提供在各种同步模型中传播同步上下文的基本功能。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
继承
SynchronizationContextSynchronizationContextSynchronizationContextSynchronizationContext
派生

注解

SynchronizationContext类是一个基类, 可提供无同步的自由线程上下文。The SynchronizationContext class is a base class that provides a free-threaded context with no synchronization.

此类实现的同步模型的目的是允许公共语言运行时的内部异步/同步操作在不同的同步模型下正常运行。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. 此模型还简化了托管应用程序必须遵循的一些要求, 以便在不同的同步环境下正常运行。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() SynchronizationContext() SynchronizationContext()

创建 SynchronizationContext 类的新实例。Creates a new instance of the SynchronizationContext class.

属性

Current Current Current Current

获取当前线程的同步上下文。Gets the synchronization context for the current thread.

方法

CreateCopy() CreateCopy() CreateCopy() CreateCopy()

在派生类中重写时,创建同步上下文的副本。When overridden in a derived class, creates a copy of the synchronization context.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsWaitNotificationRequired() IsWaitNotificationRequired() IsWaitNotificationRequired() IsWaitNotificationRequired()

确定是否需要等待通知。Determines if wait notification is required.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
OperationCompleted() OperationCompleted() OperationCompleted() OperationCompleted()

在派生类中重写时,响应操作已完成的通知。When overridden in a derived class, responds to the notification that an operation has completed.

OperationStarted() OperationStarted() OperationStarted() OperationStarted()

在派生类中重写时,响应操作已开始的通知。When overridden in a derived class, responds to the notification that an operation has started.

Post(SendOrPostCallback, Object) Post(SendOrPostCallback, Object) Post(SendOrPostCallback, Object) Post(SendOrPostCallback, Object)

在派生类中重写时,将异步消息分派到同步上下文。When overridden in a derived class, dispatches an asynchronous message to a synchronization context.

Send(SendOrPostCallback, Object) Send(SendOrPostCallback, Object) Send(SendOrPostCallback, Object) Send(SendOrPostCallback, Object)

在派生类中重写时,将同步消息分派到同步上下文。When overridden in a derived class, dispatches a synchronous message to a synchronization context.

SetSynchronizationContext(SynchronizationContext) SetSynchronizationContext(SynchronizationContext) SetSynchronizationContext(SynchronizationContext) SetSynchronizationContext(SynchronizationContext)

设置当前同步上下文。Sets the current synchronization context.

SetThreadStaticContext(SynchronizationContext) SetThreadStaticContext(SynchronizationContext) SetThreadStaticContext(SynchronizationContext) SetThreadStaticContext(SynchronizationContext)
SetWaitNotificationRequired() SetWaitNotificationRequired() SetWaitNotificationRequired() SetWaitNotificationRequired()

设置指示需要等待通知的通知,并准备回调方法以使其在发生等待时可以更可靠地被调用。Sets notification that wait notification is required and prepares the callback method so it can be called more reliably when a wait occurs.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
Wait(IntPtr[], Boolean, Int32) Wait(IntPtr[], Boolean, Int32) Wait(IntPtr[], Boolean, Int32) Wait(IntPtr[], Boolean, Int32)

等待指定数组中的任一元素或所有元素接收信号。Waits for any or all the elements in the specified array to receive a signal.

WaitHelper(IntPtr[], Boolean, Int32) WaitHelper(IntPtr[], Boolean, Int32) WaitHelper(IntPtr[], Boolean, Int32) 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.

适用于