DispatcherProcessingDisabled 结构

定义

表示处于禁用状态的调度程序,并提供重新启用调度程序处理的方法。

C#
public struct DispatcherProcessingDisabled : IDisposable
继承
DispatcherProcessingDisabled
实现

示例

以下示例演示如何禁用调度程序处理并重新启用调度程序处理。 DisableProcessingusing 语句中调用。 DisableProcessing 返回一个 DispatcherProcessingDisabled 结构,该结构用作 在使用 块完成时要释放的对象。 调用DisposeDispatcherProcessingDisabled结构可重新启用调度程序处理。

C#
// The Dispose() method is called at the end of the using statement.
// Calling Dispose on the DispatcherProcessingDisabled structure, 
// which is returned from the call to DisableProcessing, will
// re-enalbe Dispatcher processing.
using (Dispatcher.DisableProcessing())
{
    // Do work while the dispatcher processing is disabled.
    Thread.Sleep(2000);
}

注解

DisableProcessing 调用对象时返回对象 DispatcherProcessingDisabled

禁用调度程序处理是一种高级方法,旨在消除不相关的重新进入的可能性。

禁用处理的效果如下:

  • CLR 锁不会在内部泵送消息。

  • DispatcherFrame 不允许推送对象。

  • 不允许消息处理。

调用DisposeDispatcherProcessingDisabled对象将重新启用调度程序处理。

方法

Dispose()

重新启用调度程序处理。

Equals(Object)

确定指定的 DispatcherProcessingDisabled 对象是否等同于此 DispatcherProcessingDisabled 对象。

GetHashCode()

获取此实例的哈希代码。

运算符

Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

确定两个 DispatcherProcessingDisabled 对象是否相等。

Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

确定两个 DispatcherProcessingDisabled 对象是否相等。

适用于

产品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另请参阅