CancellationTokenRegistration CancellationTokenRegistration CancellationTokenRegistration CancellationTokenRegistration Struct

定義

表示已向 CancellationToken 登錄的回呼委派。Represents a callback delegate that has been registered with a CancellationToken.

public value class CancellationTokenRegistration : IDisposable, IEquatable<System::Threading::CancellationTokenRegistration>
public struct CancellationTokenRegistration : IDisposable, IEquatable<System.Threading.CancellationTokenRegistration>
type CancellationTokenRegistration = struct
    interface IDisposable
Public Structure CancellationTokenRegistration
Implements IDisposable, IEquatable(Of CancellationTokenRegistration)
繼承
CancellationTokenRegistrationCancellationTokenRegistrationCancellationTokenRegistrationCancellationTokenRegistration
實作

備註

解除標記時, 會呼叫回呼。The callback is called when the token is canceled. 若要取消註冊回呼, 請處置對應的註冊實例。To unregister a callback, dispose the corresponding Registration instance. 如需詳細資訊和程式碼範例, 請參閱Managed 執行緒中的取消For more information and code examples see Cancellation in Managed Threads.

屬性

Token Token Token Token

取得與此註冊建立關聯的 CancellationTokenGets the CancellationToken with which this registration is associated. 若註冊並未與權杖建立關聯 (例如在註冊經過處置後),則此項目會傳回預設權杖。If the registration isn't associated with a token (such as after the registration has been disposed), this will return a default token.

方法

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

釋放 CancellationTokenRegistration 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the CancellationTokenRegistration class.

DisposeAsync() DisposeAsync() DisposeAsync() DisposeAsync()

處置註冊並從相關聯的 CancellationToken 取消註冊目標回呼。Disposes of the registration and unregisters the target callback from the associated CancellationToken.

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

判斷目前的 CancellationTokenRegistration 執行個體與指定的 CancellationTokenRegistration 是否相等。Determines whether the current CancellationTokenRegistration instance is equal to the specified CancellationTokenRegistration.

Equals(CancellationTokenRegistration) Equals(CancellationTokenRegistration) Equals(CancellationTokenRegistration) Equals(CancellationTokenRegistration)

判斷目前的 CancellationTokenRegistration 執行個體與指定的 CancellationTokenRegistration 是否相等。Determines whether the current CancellationTokenRegistration instance is equal to the specified CancellationTokenRegistration.

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

做為 CancellationTokenRegistration 的雜湊函式。Serves as a hash function for a CancellationTokenRegistration.

Unregister() Unregister() Unregister() Unregister()

處置註冊並從相關聯的 CancellationToken 取消註冊目標回呼。Disposes of the registration and unregisters the target callback from the associated CancellationToken.

運算子

Equality(CancellationTokenRegistration, CancellationTokenRegistration) Equality(CancellationTokenRegistration, CancellationTokenRegistration) Equality(CancellationTokenRegistration, CancellationTokenRegistration) Equality(CancellationTokenRegistration, CancellationTokenRegistration)

判斷兩個 CancellationTokenRegistration 執行個體是否相等。Determines whether two CancellationTokenRegistration instances are equal.

Inequality(CancellationTokenRegistration, CancellationTokenRegistration) Inequality(CancellationTokenRegistration, CancellationTokenRegistration) Inequality(CancellationTokenRegistration, CancellationTokenRegistration) Inequality(CancellationTokenRegistration, CancellationTokenRegistration)

判斷兩個 CancellationTokenRegistration 執行個體是否不相等。Determines whether two CancellationTokenRegistration instances are not equal.

適用於

執行緒安全性

所有的CancellationTokenRegistration公用和受保護成員都是安全線程, 而且可以從多個執行緒同時使用, 但 Dispose 除外, 只有在上的CancellationTokenRegistration所有其他作業都已完成時才需要使用。All public and protected members of CancellationTokenRegistration are thread-safe and may be used concurrently from multiple threads, with the exception of Dispose, which must only be used when all other operations on the CancellationTokenRegistration have completed.

另請參閱