TaskCompletionSource.TrySetCanceled Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
TrySetCanceled() |
Attempts to transition the underlying Task into the Canceled state. |
TrySetCanceled(CancellationToken) |
Attempts to transition the underlying Task into the Canceled state. |
TrySetCanceled()
- Source:
- TaskCompletionSource.cs
- Source:
- TaskCompletionSource.cs
- Source:
- TaskCompletionSource.cs
public:
bool TrySetCanceled();
public bool TrySetCanceled ();
member this.TrySetCanceled : unit -> bool
Public Function TrySetCanceled () As Boolean
Returns
true
if the operation was successful; otherwise, false
.
Remarks
This operation will return false
if the Task is already in one of the three final states:
RanToCompletion, Faulted, or Canceled.
Applies to
TrySetCanceled(CancellationToken)
- Source:
- TaskCompletionSource.cs
- Source:
- TaskCompletionSource.cs
- Source:
- TaskCompletionSource.cs
public:
bool TrySetCanceled(System::Threading::CancellationToken cancellationToken);
public bool TrySetCanceled (System.Threading.CancellationToken cancellationToken);
member this.TrySetCanceled : System.Threading.CancellationToken -> bool
Public Function TrySetCanceled (cancellationToken As CancellationToken) As Boolean
Parameters
- cancellationToken
- CancellationToken
The cancellation token with which to cancel the Task.
Returns
true
if the operation was successful; otherwise, false
.
Remarks
This operation will return false
if the Task is already in one of the three final states:
RanToCompletion, Faulted, or Canceled.