Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

cancellation_token Class

The cancellation_token class represents the ability to determine whether some operation has been requested to cancel.

class cancellation_token;

Name

Description

cancellation_token::cancellation_token Constructor

Overloaded. Constructs a cancellation_token object.

cancellation_token::~cancellation_token Destructor

Destructs the cancellation_token object.

Name

Description

cancellation_token::deregister_callback Method

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

cancellation_token::is_cancelable Method

Returns an indication of whether this token can be canceled or not.

cancellation_token::is_canceled Method

Returns true if the token has been canceled.

cancellation_token::none Method

Returns a cancellation token which can never be subject to cancellation.

cancellation_token::register_callback Method

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

Name

Description

cancellation_token::operator!= Operator

Determines whether two cancellation_token objects represent two different underlyign tokens.

cancellation_token::operator= Operator

Overloaded. Replaces the contents of one cancellation_token object with another.

cancellation_token::operator== Operator

Determines whether two cancellation_token objects represent the same underlying token.

Multiple cancellation_token objects can be linked to one cancellation_token_source object. When you call the cancel method on a token source, all the linked cancellation_token objects are set as canceled.

A given cancellation_token object can be associated with a task_group, structured_task_group, or task to provide implicit cancellation. It can also be polled for cancellation information or have a callback registered and called when it is canceled.

cancellation_token behaves like a smart pointer and is safe to pass around by value.

For more info about task cancellation, see Cancellation in the PPL.

cancellation_token

Header: ppl.h

Namespace: concurrency

Show:
© 2017 Microsoft