DispatcherObject Class

Definition

表示与 Dispatcher 关联的对象。Represents an object that is associated with a Dispatcher.

public ref class DispatcherObject abstract
public abstract class DispatcherObject
type DispatcherObject = class
Public MustInherit Class DispatcherObject
Inheritance
DispatcherObject
Derived

Remarks

只有创建 Dispatcher 的线程才能直接访问 DispatcherObjectOnly the thread that the Dispatcher was created on may access the DispatcherObject directly. 若要从创建 DispatcherObject 的线程以外的线程访问 DispatcherObject,请在与 Dispatcher 关联的 DispatcherObject 上调用 InvokeBeginInvokeTo access a DispatcherObject from a thread other than the thread the DispatcherObject was created on, call Invoke or BeginInvoke on the Dispatcher the DispatcherObject is associated with.

需要强制执行线程安全的 DispatcherObject 子类可以通过对所有公共方法调用 VerifyAccess 来实现此目的。Subclasses of DispatcherObject that need to enforce thread safety can do so by calling VerifyAccess on all public methods. 这可保证调用线程是在其上创建 DispatcherObject 的线程。This guarantees the calling thread is the thread that the DispatcherObject was created on.

不能单独实例化 DispatcherObject;也就是说,所有构造函数都受到保护。A DispatcherObject cannot be independently instantiated; that is, all constructors are protected.

派生自 DispatcherObject 的对象具有线程关联。Objects that derive from DispatcherObject have thread affinity.

Freezable 派生的对象在被冻结时是自由线程的。Objects that derive from Freezable are free-threaded when they are frozen. 有关详细信息,请参阅 Freezable 对象概述For more information, see the Freezable Objects Overview.

Constructors

DispatcherObject()

初始化 DispatcherObject 类的新实例。Initializes a new instance of the DispatcherObject class.

Properties

Dispatcher

获取与此 Dispatcher 关联的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

Methods

CheckAccess()

确定调用线程是否可以访问此 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

Equals(Object)

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

(Inherited from Object)
GetHashCode()

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

(Inherited from Object)
GetType()

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

(Inherited from Object)
MemberwiseClone()

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

(Inherited from Object)
ToString()

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

(Inherited from Object)
VerifyAccess()

强制调用线程具有此 DispatcherObject 的访问权限。Enforces that the calling thread has access to this DispatcherObject.

Applies to

Thread Safety

此类型的任何公共 static 成员都是线程安全的。Any public static members of this type are thread safe. 但不保证所有实例成员都是线程安全的。Any instance members are not guaranteed to be thread safe.

只能从创建此对象的线程访问此对象。This object can be accessed only from the thread on which it was created. 尝试从其他线程访问它将引发 InvalidOperationExceptionAttempts to access it from other threads will throw an InvalidOperationException. Invoke(DispatcherPriority, Delegate)BeginInvoke(DispatcherPriority, Delegate) 为封送处理正确的线程提供支持。Invoke(DispatcherPriority, Delegate) or BeginInvoke(DispatcherPriority, Delegate) provide support for marshaling work to the correct thread.