CancellationToken.UnsafeRegister(Action<Object>, Object) Método

Definição

Registra um delegado chamado quando este CancellationToken é cancelado.Registers a delegate that is called when this CancellationToken is canceled.

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

Parâmetros

callback
Action<Object>

O delegado a ser executado quando o CancellationToken é cancelado.The delegate to execute when the CancellationToken is canceled.

state
Object

O estado a ser passado para a callback quando o delegado é invocado.The state to pass to the callback when the delegate is invoked. Isso pode ser null.This may be null.

Retornos

CancellationTokenRegistration

Um objeto que pode ser usado para cancelar o registro do retorno de chamada.An object that can be used to unregister the callback.

Exceções

callback é nulo.callback is null.

Comentários

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.

O ExecutionContext não é capturado nem fluido para a invocação do retorno de chamada.The ExecutionContext is not captured nor flowed to the callback's invocation.

Aplica-se a