DispatcherProcessingDisabled 結構

定義

表示停用狀態的發送器並提供重新啟用發送器處理的方法。

public value class DispatcherProcessingDisabled : IDisposable
public struct DispatcherProcessingDisabled : IDisposable
type DispatcherProcessingDisabled = struct
    interface IDisposable
Public Structure DispatcherProcessingDisabled
Implements IDisposable
繼承
DispatcherProcessingDisabled
實作

範例

下列範例示範如何停用發送器處理並重新啟用發送器處理。 DisableProcessingusing 語句中呼叫 。 DisableProcessingDispatcherProcessingDisabled會傳回 結構,當做使用區塊完成時要處置的物件。 在 結構上 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

備註

DisableProcessingDispatcherProcessingDisabled呼叫 物件時會傳回 物件。

停用發送器處理是一種進階方法,旨在消除不相關的重新進入的機會。

停用處理的效果如下所示:

  • CLR 鎖定不會在內部幫浦訊息。

  • DispatcherFrame 不允許推送物件。

  • 不允許訊息處理。

在 物件上 DispatcherProcessingDisabled 呼叫 Dispose 將會重新啟用發送器處理。

方法

Dispose()

重新啟用發送器處理。

Equals(Object)

判斷指定的 DispatcherProcessingDisabled 物件是否等於這個 DispatcherProcessingDisabled 物件。

GetHashCode()

取得這個執行個體的雜湊碼。

運算子

Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

判斷兩個 DispatcherProcessingDisabled 物件是否相等。

Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

判斷兩個 DispatcherProcessingDisabled 物件是否不相等。

適用於

另請參閱