Dispatcher.DisableProcessing Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Returns
A structure used to re-enable dispatcher processing.
Examples
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 that is used as the object to be disposed when the using block finishes. 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
Remarks
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.
The DispatcherProcessingDisabled structure that DisableProcessing returns when it is called can be used to re-enable dispatcher processing. Calling Dispose on the DispatcherProcessingDisabled structure re-enables processing.
DisableProcessing can only be called on the thread the Dispatcher is associated with.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기