DispatcherObject DispatcherObject DispatcherObject DispatcherObject Class

定义

表示与 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
继承
DispatcherObjectDispatcherObjectDispatcherObjectDispatcherObject
派生

注解

只有创建的线程Dispatcher才能DispatcherObject直接访问。Only the thread that the Dispatcher was created on may access the DispatcherObject directly. 若要DispatcherObject从创建的线程以外DispatcherObject的线程访问Dispatcher , 请调用Invoke上的或BeginInvoke与关联的DispatcherObjectTo 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.

需要强制执行线程安全的子类可以通过调用VerifyAccess所有公共方法来实现此目的。 DispatcherObjectSubclasses 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.

构造函数

DispatcherObject() DispatcherObject() DispatcherObject() DispatcherObject()

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

属性

Dispatcher Dispatcher Dispatcher Dispatcher

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

方法

CheckAccess() CheckAccess() CheckAccess() CheckAccess()

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

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)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)
VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

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

适用于

线程安全性

此类型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.