DispatcherProcessingDisabled DispatcherProcessingDisabled DispatcherProcessingDisabled DispatcherProcessingDisabled Struct

定義

表示停用狀態的發送器並提供重新啟用發送器處理的方法。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
繼承
DispatcherProcessingDisabledDispatcherProcessingDisabledDispatcherProcessingDisabledDispatcherProcessingDisabled
實作

範例

下列範例示範如何停用發送器處理,然後重新啟用發送器處理。The following example shows how to disable dispatcher processing and re-enable dispatcher processing. DisableProcessing 在中,稱為使用陳述式。DisableProcessing is called in a using statement. DisableProcessing 會傳回DispatcherProcessingDisabled結構,用以做為物件被處置時使用封鎖完成。DisableProcessing returns a DispatcherProcessingDisabled structure which is used as the object to be disposed when the using block finishes. 呼叫DisposeDispatcherProcessingDisabled結構重新啟用發送器處理。Calling 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 傳回DispatcherProcessingDisabled物件時呼叫它。DisableProcessing 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.

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

方法

Dispose() Dispose() Dispose() Dispose()

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

運算子

Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled) Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled) Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled) Equality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

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

Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled) Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled) Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled) Inequality(DispatcherProcessingDisabled, DispatcherProcessingDisabled)

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

適用於

另請參閱