DispatcherProcessingDisabled Structure

Represents the Dispatcher when it is in a disable state and provides a means to re-enable dispatcher processing.

Namespace:  System.Windows.Threading
Assembly:  WindowsBase (in WindowsBase.dll)

public struct DispatcherProcessingDisabled : IDisposable

The DispatcherProcessingDisabled type exposes the following members.

  NameDescription
Public methodDisposeRe-enables dispatcher processing.
Public methodEqualsDetermines whether the specified DispatcherProcessingDisabled object is equal to this DispatcherProcessingDisabled object. (Overrides ValueType.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeGets a hash code for this instance. (Overrides ValueType.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns the fully qualified type name of this instance. (Inherited from ValueType.)
Top

  NameDescription
Public operatorStatic memberEqualityDetermines whether two DispatcherProcessingDisabled objects are equal.
Public operatorStatic memberInequalityDetermines whether two DispatcherProcessingDisabled objects are not equal.
Top

DisableProcessing returns a DispatcherProcessingDisabled object when it is called.

Disabling dispatcher processing is an advanced method that is intended to eliminate the chance of unrelated reentrancy.

The effects of disabling processing are as follows:

  • CLR locks will not pump messages internally.

  • DispatcherFrame objects are not allowed to be pushed.

  • Message processing is not permitted.

Calling Dispose on the DispatcherProcessingDisabled object will re-enable dispatcher processing.

The following example shows how to disable dispatcher processing and re-enable dispatcher processing. DisableProcessing is called in a using statement. DisableProcessing returns a DispatcherProcessingDisabled structure which is used as the object to be disposed when the using block finishes. Calling Dispose on the DispatcherProcessingDisabled structure re-enables dispatcher processing.


// 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);
}


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft