Share via


cancellation_token::register_callback Method

Registers a callback function that is invoked when the cancellation token is canceled.

template<
   typename _Function
>
cancellation_token_registration register_callback(
   const _Function& _Func
) const;

Parameters

  • _Function
    The type of the function object that will be invoked when this cancellation_token is canceled.

  • _Func
    The function object that will be invoked when this cancellation_token is canceled.

Return Value

A cancellation_token_registration object which can be utilized in the deregister_callback method to deregister a previously registered callback and prevent it from being made.

Remarks

If the token is already canceled at the point where this method is called, the callback is invoked immediately and synchronously.

This method throws invalid_operation exception if it is called on a cancellation_token object that was created by using the cancellation_token::none method.

Requirements

Header: ppl.h

Namespace: concurrency

See Also

Reference

cancellation_token Class