共用方式為


CancellationToken.UnsafeRegister 方法

定義

多載

UnsafeRegister(Action<Object,CancellationToken>, Object)

註冊取消此 CancellationToken 時所呼叫的委派。

UnsafeRegister(Action<Object>, Object)

註冊取消此 CancellationToken 時要呼叫的委派。

UnsafeRegister(Action<Object,CancellationToken>, Object)

註冊取消此 CancellationToken 時所呼叫的委派。

public:
 System::Threading::CancellationTokenRegistration UnsafeRegister(Action<System::Object ^, System::Threading::CancellationToken> ^ callback, System::Object ^ state);
public System.Threading.CancellationTokenRegistration UnsafeRegister (Action<object?,System.Threading.CancellationToken> callback, object? state);
member this.UnsafeRegister : Action<obj, System.Threading.CancellationToken> * obj -> System.Threading.CancellationTokenRegistration
Public Function UnsafeRegister (callback As Action(Of Object, CancellationToken), state As Object) As CancellationTokenRegistration

參數

callback
Action<Object,CancellationToken>

取消 CancellationToken時要執行的委派。

state
Object

當叫用委派時,要傳遞給 callback 的狀態。 這可能是 null

傳回

CancellationTokenRegistration

可用來取消註冊回呼的 CancellationTokenRegistration 執行個體。

例外狀況

callbacknull

備註

如果此權杖已處於已取消狀態,則會立即和同步執行委派。 委派產生的任何例外狀況都會從這個方法呼叫中傳播。 ExecutionContext 不會擷取或流向回呼的調用。

適用於

UnsafeRegister(Action<Object>, Object)

註冊取消此 CancellationToken 時要呼叫的委派。

public:
 System::Threading::CancellationTokenRegistration UnsafeRegister(Action<System::Object ^> ^ callback, System::Object ^ state);
public System.Threading.CancellationTokenRegistration UnsafeRegister (Action<object?> callback, object? state);
member this.UnsafeRegister : Action<obj> * obj -> System.Threading.CancellationTokenRegistration
Public Function UnsafeRegister (callback As Action(Of Object), state As Object) As CancellationTokenRegistration

參數

callback
Action<Object>

取消 CancellationToken 時要執行的委派。

state
Object

當叫用委派時,要傳遞給 callback 的狀態。 這可能是 null

傳回

CancellationTokenRegistration

可用來取消註冊回呼的物件。

例外狀況

callback 為 null。

備註

If this token is already in the canceled state, the delegate is run immediately and synchronously. Any exception the delegate generates is propagated out of this method call.

ExecutionContext不會擷取或流向回呼的調用。

適用於