Dispatcher.DisableProcessing Método

Definição

Desabilita o processamento da fila 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

Retornos

Uma estrutura usada para habilitar novamente o processamento do dispatcher.A structure used to re-enable dispatcher processing.

Exemplos

O exemplo a seguir mostra como desabilitar o processamento do Dispatcher e reabilitar o processamento do Dispatcher.The following example shows how to disable dispatcher processing and re-enable dispatcher processing. DisableProcessingé chamado em uma instrução using .DisableProcessing is called in a using statement. DisableProcessingRetorna uma DispatcherProcessingDisabled estrutura que é usada como o objeto a ser Descartado quando o bloco using é concluído.DisableProcessing returns a DispatcherProcessingDisabled structure that is used as the object to be disposed when the using block finishes. Quando Dispose é chamado DispatcherProcessingDisabled na estrutura, o processamento do Dispatcher é habilitado novamente.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

Comentários

A desabilitação do processamento do Dispatcher é um método avançado que se destina a eliminar a chance de reentrância não relacionada.Disabling dispatcher processing is an advanced method that is intended to eliminate the chance of unrelated reentrancy.

Os efeitos da desabilitação do processamento são os seguintes:The effects of disabling processing are as follows:

  • Os bloqueios de CLR não Bombeam as mensagens internamente.CLR locks will not pump messages internally.

  • DispatcherFrameos objetos não podem ser enviados por push.DispatcherFrame objects are not allowed to be pushed.

  • O processamento de mensagens não é permitido.Message processing is not permitted.

A DispatcherProcessingDisabled estrutura que DisableProcessing retorna quando é chamada pode ser usada para reabilitar o processamento do Dispatcher.The DispatcherProcessingDisabled structure that DisableProcessing returns when it is called can be used to re-enable dispatcher processing. A Dispose chamada na DispatcherProcessingDisabled estrutura habilita o processamento novamente.Calling Dispose on the DispatcherProcessingDisabled structure re-enables processing.

DisableProcessingSó pode ser chamado no thread ao qual Dispatcher o está associado.DisableProcessing can only be called on the thread the Dispatcher is associated with.

Aplica-se a