4.10.0 (latest) 4.8.0 4.4.0 4.3.1 4.2.0 4.0.0 3.2.0

    public static class TaskCompletionSourceExtensions

Extension methods for [TaskCompletionSource\<TResult\>](https://learn.microsoft.com/dotnet/api/system.threading.tasks.taskcompletionsource-1).

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> TaskCompletionSourceExtensions

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Api.Gax](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.md.txt)

## Assembly

Google.Api.Gax.dll

## Methods

### WithCancellationToken\<TResult\>(TaskCompletionSource\<TResult\>, CancellationToken)

    public static Task<TResult> WithCancellationToken<TResult>(this TaskCompletionSource<TResult> source, CancellationToken cancellationToken)

Returns a task from a task completion source, but observing a given cancellation token.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `source` | `TaskCompletionSource` The task completion source. Must not be null. |
| `cancellationToken` | `CancellationToken` The cancellation token to observe. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` | A task that will complete when `source` completes, but will observe `cancellationToken` for cancellation. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `TResult` | The result type of the task completion source |