Dispatcher.DisableProcessing Dispatcher.DisableProcessing Dispatcher.DisableProcessing Dispatcher.DisableProcessing Method

定義

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

戻り値

ディスパッチャー処理を再度有効にするために使用される構造体。A structure used to re-enable dispatcher processing.

次の例では、ディスパッチャー処理を無効にして、ディスパッチャー処理を再度有効にする方法を示します。The following example shows how to disable dispatcher processing and re-enable dispatcher processing. DisableProcessingは、 usingステートメントで呼び出されます。DisableProcessing is called in a using statement. DisableProcessing使用ブロックが終了したときに破棄されるオブジェクトとし**** て使用される構造体を返します。DispatcherProcessingDisabledDisableProcessing returns a DispatcherProcessingDisabled structure that is used as the object to be disposed when the using block finishes. 構造DispatcherProcessingDisabled体でが呼び出されるとDispose 、ディスパッチャー処理が再度有効になります。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

注釈

ディスパッチャー処理の無効化は、関連性のない再入の可能性を排除することを目的とした高度な手法です。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 ロックは、内部的にメッセージをポンプしません。CLR locks will not pump messages internally.

  • DispatcherFrameオブジェクトのプッシュは許可されていません。DispatcherFrame objects are not allowed to be pushed.

  • メッセージ処理は許可されていません。Message processing is not permitted.

を呼び出したときにを返すDispatcherProcessingDisabled構造体は、ディスパッチャーの処理を再度有効にするために使用できます。 DisableProcessingThe DispatcherProcessingDisabled structure that DisableProcessing returns when it is called can be used to re-enable dispatcher processing. 構造DispatcherProcessingDisabled体でを呼び出すDisposeと、処理が再度有効になります。Calling Dispose on the DispatcherProcessingDisabled structure re-enables processing.

DisableProcessingは、 Dispatcherが関連付けられているスレッドでのみ呼び出すことができます。DisableProcessing can only be called on the thread the Dispatcher is associated with.

適用対象