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.

TaskCompletionSource<TResult>::TrySetCanceled Method (CancellationToken)

.NET Framework (current version)
 

Attempts to transition the underlying Task<TResult> into the TaskStatus::Canceled state and enables a cancellation token to be stored in the canceled task.

Namespace:   System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

public:
bool TrySetCanceled(
	CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading::CancellationToken

A cancellation token.

Return Value

Type: System::Boolean

true if the operation is successful; otherwise, false.

The method returns false if the underlying Task<TResult> object is already in one of the following three final states.

This method also returns false if the underlying Task<TResult> object has already been disposed.

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.6
Return to top
Show:
© 2017 Microsoft