DispatcherProcessingDisabled 結構

定義

表示停用狀態的發送器並提供重新啟用發送器處理的方法。Represents the Dispatcher when it is in a disable state and provides a means to re-enable dispatcher processing.

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

範例

下列範例示範如何停用發送器處理和重新啟用發送器處理。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 which is used as the object to be disposed when the using block finishes. 在結構上呼叫Dispose會重新啟用發送器處理。DispatcherProcessingDisabledCalling Dispose on the DispatcherProcessingDisabled structure re-enables dispatcher processing.

// 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

備註

DisableProcessing在呼叫時傳回物件。DispatcherProcessingDisabledDisableProcessing returns a DispatcherProcessingDisabled object when it is called.

停用發送器處理是一個先進的方法, 目的是要消除不相關重新進入的機會。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.

在物件上呼叫Dispose將會重新啟用發送器處理。DispatcherProcessingDisabledCalling Dispose on the DispatcherProcessingDisabled object will re-enable dispatcher processing.

方法

Dispose()

重新啟用發送器處理。Re-enables dispatcher processing.

Equals(Object)

判斷指定的 DispatcherProcessingDisabled 物件是否等於這個 DispatcherProcessingDisabled 物件。Determines whether the specified DispatcherProcessingDisabled object is equal to this DispatcherProcessingDisabled object.

GetHashCode()

取得這個執行個體的雜湊碼。Gets a hash code for this instance.

運算子

Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

判斷兩個 DispatcherProcessingDisabled 物件是否相等。Determines whether two DispatcherProcessingDisabled objects are equal.

Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

判斷兩個 DispatcherProcessingDisabled 物件是否不相等。Determines whether two DispatcherProcessingDisabled objects are not equal.

適用於

另請參閱