Dispatcher.DisableProcessing Método

Definición

Deshabilita el procesamiento de la cola de Dispatcher.Disables processing of the Dispatcher queue.

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.A structure used to re-enable dispatcher processing.

Ejemplos

En el ejemplo siguiente se muestra cómo deshabilitar el procesamiento del distribuidor y volver a habilitar el procesamiento del distribuidor.The following example shows how to disable dispatcher processing and re-enable dispatcher processing. DisableProcessing se llama a en una instrucción using .DisableProcessing is called in a using statement. DisableProcessing Devuelve una DispatcherProcessingDisabled estructura que se utiliza como el objeto que se va a eliminar cuando finalice el bloque using .DisableProcessing returns a DispatcherProcessingDisabled structure that is used as the object to be disposed when the using block finishes. Cuando Dispose se llama a en la DispatcherProcessingDisabled estructura, se vuelve a habilitar el procesamiento del distribuidor.When Dispose is called on the DispatcherProcessingDisabled structure, dispatcher processing is re-enabled.

// 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 diseñado para eliminar la posibilidad de una reentrada no relacionada.Disabling dispatcher processing is an advanced method that is intended to eliminate the chance of unrelated reentrancy.

Los efectos de deshabilitar el procesamiento son los siguientes:The effects of disabling processing are as follows:

  • Los bloqueos CLR no bombearán mensajes internamente.CLR locks will not pump messages internally.

  • DispatcherFrame no se permite la inserción de objetos.DispatcherFrame objects are not allowed to be pushed.

  • No se permite el procesamiento de mensajes.Message processing is not permitted.

La DispatcherProcessingDisabled estructura que DisableProcessing devuelve cuando se llama a se puede usar para volver a habilitar el procesamiento del distribuidor.The DispatcherProcessingDisabled structure that DisableProcessing returns when it is called can be used to re-enable dispatcher processing. Al llamar a Dispose en la DispatcherProcessingDisabled estructura, se vuelve a habilitar el procesamiento.Calling Dispose on the DispatcherProcessingDisabled structure re-enables processing.

DisableProcessing solo se puede llamar a en el subproceso al que Dispatcher está asociado.DisableProcessing can only be called on the thread the Dispatcher is associated with.

Se aplica a