Dispatcher.DisableProcessing Método

Definición

Deshabilita el procesamiento de la cola de Dispatcher.

public:
 System::Windows::Threading::DispatcherProcessingDisabled DisableProcessing();
public System.Windows.Threading.DispatcherProcessingDisabled DisableProcessing ();
member this.DisableProcessing : unit -> System.Windows.Threading.DispatcherProcessingDisabled
Public Function DisableProcessing () As DispatcherProcessingDisabled

Devoluciones

DispatcherProcessingDisabled

Estructura usada para volver a habilitar el procesamiento del distribuidor.

Ejemplos

En el ejemplo siguiente se muestra cómo deshabilitar el procesamiento del distribuidor y volver a habilitar el procesamiento del distribuidor. DisableProcessing se llama a en una instrucción using . DisableProcessing devuelve una DispatcherProcessingDisabled estructura que se usa como objeto que se va a eliminar cuando finaliza el bloque using . Cuando Dispose se llama a en la DispatcherProcessingDisabled estructura , se vuelve a habilitar el procesamiento del distribuidor.

// 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);
}
' 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-enable Dispatcher processing.
Using Dispatcher.DisableProcessing()
    ' Do work while the dispatcher processing is disabled.
    Thread.Sleep(2000)
End Using

Comentarios

Deshabilitar el procesamiento del distribuidor es un método avanzado destinado a eliminar la posibilidad de reentrada no relacionada.

Los efectos de deshabilitar el procesamiento son los siguientes:

  • Los bloqueos CLR no bombean mensajes internamente.

  • DispatcherFrame No se permite insertar objetos.

  • No se permite el procesamiento de mensajes.

La DispatcherProcessingDisabled estructura que DisableProcessing devuelve cuando se llama se puede usar para volver a habilitar el procesamiento del distribuidor. Al llamar a en la estructura, se vuelve a Dispose habilitar el DispatcherProcessingDisabled procesamiento.

DisableProcessing solo se puede llamar a en el subproceso al que Dispatcher está asociado.

Se aplica a