Dispatcher.DisableProcessing メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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
返品
ディスパッチャー処理を再度有効にするために使用される構造体。
例
次の例は、ディスパッチャー処理を無効にし、ディスパッチャー処理を再度有効にする方法を示しています。 DisableProcessing は using ステートメントで呼び出されます。 DisableProcessing は、using ブロックの終了時に破棄されるオブジェクトとして使用される DispatcherProcessingDisabled 構造体 を 返します。 DispatcherProcessingDisabled構造体でDisposeが呼び出されると、ディスパッチャー処理が再度有効になります。
// 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
注釈
ディスパッチャー処理を無効にすることは、関連のない再入の可能性を排除することを目的とした高度な方法です。
処理を無効にした場合の影響は次のとおりです。
CLR ロックは、メッセージを内部的にポンプしません。
DispatcherFrame オブジェクトはプッシュできません。
メッセージ処理は許可されません。
呼び出されたときにDisableProcessingが返すDispatcherProcessingDisabled構造体は、ディスパッチャー処理を再度有効にするために使用できます。 DispatcherProcessingDisabled構造体でDisposeを呼び出すと、処理が再度有効になります。
DisableProcessing は、 Dispatcher が関連付けられているスレッドでのみ呼び出すことができます。