CancellationToken.Register Método

Definición

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

Sobrecargas

Register(Action)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

Register(Action, Boolean)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

Register(Action<Object>, Object)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

Register(Action<Object>, Object, Boolean)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

Register(Action)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

public:
 System::Threading::CancellationTokenRegistration Register(Action ^ callback);
public System.Threading.CancellationTokenRegistration Register (Action callback);
member this.Register : Action -> System.Threading.CancellationTokenRegistration
Public Function Register (callback As Action) As CancellationTokenRegistration

Parámetros

callback
Action

Delegado que se va a ejecutar cuando se cancele CancellationToken.The delegate to be executed when the CancellationToken is canceled.

Devoluciones

Instancia de CancellationTokenRegistration que se puede usar para anular el registro de la devolución de llamada.The CancellationTokenRegistration instance that can be used to unregister the callback.

Excepciones

Se eliminó el CancellationTokenSource asociado.The associated CancellationTokenSource has been disposed.

callback es null.callback is null.

Comentarios

Si este token ya está en estado cancelado, el delegado se ejecutará inmediatamente y de forma sincrónica.If this token is already in the canceled state, the delegate will be run immediately and synchronously. Cualquier excepción generada por el delegado se propagará fuera de esta llamada al método.Any exception the delegate generates will be propagated out of this method call.

El @no__t actual-0 se captura junto con el delegado y se utilizará cuando se ejecute.The current ExecutionContext is captured along with the delegate and will be used when executing it.

No se captura el @no__t actual-0.The current SynchronizationContext is not captured.

Consulte también:

Register(Action, Boolean)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

public:
 System::Threading::CancellationTokenRegistration Register(Action ^ callback, bool useSynchronizationContext);
public System.Threading.CancellationTokenRegistration Register (Action callback, bool useSynchronizationContext);
member this.Register : Action * bool -> System.Threading.CancellationTokenRegistration
Public Function Register (callback As Action, useSynchronizationContext As Boolean) As CancellationTokenRegistration

Parámetros

callback
Action

Delegado que se va a ejecutar cuando se cancele CancellationToken.The delegate to be executed when the CancellationToken is canceled.

useSynchronizationContext
Boolean

Un valor que indica si se va a capturar el SynchronizationContext actual y si se va a usar al invocar callback.A value that indicates whether to capture the current SynchronizationContext and use it when invoking the callback.

Devoluciones

Instancia de CancellationTokenRegistration que se puede usar para anular el registro de la devolución de llamada.The CancellationTokenRegistration instance that can be used to unregister the callback.

Excepciones

Se eliminó el CancellationTokenSource asociado.The associated CancellationTokenSource has been disposed.

callback es null.callback is null.

Comentarios

Si este token ya está en estado cancelado, el delegado se ejecutará inmediatamente y de forma sincrónica.If this token is already in the canceled state, the delegate will be run immediately and synchronously. Cualquier excepción generada por el delegado se propagará fuera de esta llamada al método.Any exception the delegate generates will be propagated out of this method call.

El @no__t actual-0 se captura junto con el delegado y se utilizará cuando se ejecute.The current ExecutionContext is captured along with the delegate and will be used when executing it.

Si useSynchronizationContext es true, el @no__t actual-2, si existe, también se captura junto con el delegado y se utilizará cuando se ejecute.If useSynchronizationContext is true, the current SynchronizationContext, if one exists, is also captured along with the delegate and will be used when executing it. De lo contrario, SynchronizationContext no se captura.Otherwise, SynchronizationContext is not captured.

Consulte también:

Register(Action<Object>, Object)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

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

Parámetros

callback
Action<Object>

Delegado que se va a ejecutar cuando se cancele CancellationToken.The delegate to be executed when the CancellationToken is canceled.

state
Object

El estado que se va a pasar a callback cuando se invoque al delegado.The state to pass to the callback when the delegate is invoked. Puede ser null.This may be null.

Devoluciones

Instancia de CancellationTokenRegistration que se puede usar para anular el registro de la devolución de llamada.The CancellationTokenRegistration instance that can be used to unregister the callback.

Excepciones

Se eliminó el CancellationTokenSource asociado.The associated CancellationTokenSource has been disposed.

callback es null.callback is null.

Comentarios

Si este token ya está en estado cancelado, el delegado se ejecutará inmediatamente y de forma sincrónica.If this token is already in the canceled state, the delegate will be run immediately and synchronously. Cualquier excepción generada por el delegado se propagará fuera de esta llamada al método.Any exception the delegate generates will be propagated out of this method call.

El @no__t actual-0 se captura junto con el delegado y se utilizará cuando se ejecute.The current ExecutionContext is captured along with the delegate and will be used when executing it.

No se captura el @no__t actual-0.The current SynchronizationContext is not captured.

Consulte también:

Register(Action<Object>, Object, Boolean)

Registra un delegado que se invocará cuando se cancele este objeto CancellationToken.Registers a delegate that will be called when this CancellationToken is canceled.

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

Parámetros

callback
Action<Object>

Delegado que se va a ejecutar cuando se cancele CancellationToken.The delegate to be executed when the CancellationToken is canceled.

state
Object

El estado que se va a pasar a callback cuando se invoque al delegado.The state to pass to the callback when the delegate is invoked. Puede ser null.This may be null.

useSynchronizationContext
Boolean

Un valor booleano que indica si se va a capturar el SynchronizationContext actual y si se va a usar al invocar callback.A Boolean value that indicates whether to capture the current SynchronizationContext and use it when invoking the callback.

Devoluciones

Instancia de CancellationTokenRegistration que se puede usar para anular el registro de la devolución de llamada.The CancellationTokenRegistration instance that can be used to unregister the callback.

Excepciones

Se eliminó el CancellationTokenSource asociado.The associated CancellationTokenSource has been disposed.

callback es null.callback is null.

Comentarios

Si este token ya está en estado cancelado, el delegado se ejecutará inmediatamente y de forma sincrónica.If this token is already in the canceled state, the delegate will be run immediately and synchronously. Cualquier excepción generada por el delegado se propagará fuera de esta llamada al método.Any exception the delegate generates will be propagated out of this method call.

El @no__t actual-0 se captura junto con el delegado y se utilizará cuando se ejecute.The current ExecutionContext is captured along with the delegate and will be used when executing it.

Si useSynchronizationContext es true, el @no__t actual-2, si existe, también se captura junto con el delegado y se utilizará cuando se ejecute.If useSynchronizationContext is true, the current SynchronizationContext, if one exists, is also captured along with the delegate and will be used when executing it. De lo contrario, SynchronizationContext no se captura.Otherwise, SynchronizationContext is not captured.

Consulte también:

Se aplica a