<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.10.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.TaskExtensions.md.txt)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.TaskExtensions.md.txt)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.TaskExtensions.md.txt)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.TaskExtensions.md.txt)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.TaskExtensions.md.txt)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.TaskExtensions.md.txt)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.TaskExtensions.md.txt)

    public static class TaskExtensions

Extension methods for tasks.

## Inheritance

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

## 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

### ResultWithUnwrappedExceptions\<T\>(Task\<T\>)

    public static T ResultWithUnwrappedExceptions<T>(this Task<T> task)

Synchronously waits for the given task to complete, and returns the result.
Any [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception) thrown is unwrapped to the first inner exception.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `task` | `Task` The task to wait for. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | The result of the completed task. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The result type of the task |

### WaitWithUnwrappedExceptions(Task)

    public static void WaitWithUnwrappedExceptions(this Task task)

Synchronously waits for the given task to complete.
Any [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception) thrown is unwrapped to the first inner exception.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `task` | `Task` The task to wait for. |

### WaitWithUnwrappedExceptions(Task, int)

    public static bool WaitWithUnwrappedExceptions(this Task task, int millisecondsTimeout)

Synchronously waits for the given task to complete.
Any [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception) thrown is unwrapped to the first inner exception.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `task` | `Task` The task to wait for. |
| `millisecondsTimeout` | `int` The number of milliseconds to wait, or -1 to wait indefinitely. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### WaitWithUnwrappedExceptions(Task, int, CancellationToken)

    public static bool WaitWithUnwrappedExceptions(this Task task, int millisecondsTimeout, CancellationToken cancellationToken)

Synchronously waits for the given task to complete.
Any [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception) thrown is unwrapped to the first inner exception.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `task` | `Task` The task to wait for. |
| `millisecondsTimeout` | `int` The number of milliseconds to wait, or -1 to wait indefinitely. |
| `cancellationToken` | `CancellationToken` A cancellation token to observe while waiting for the task to complete |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### WaitWithUnwrappedExceptions(Task, CancellationToken)

    public static void WaitWithUnwrappedExceptions(this Task task, CancellationToken cancellationToken)

Synchronously waits for the given task to complete.
Any [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception) thrown is unwrapped to the first inner exception.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `task` | `Task` The task to wait for. |
| `cancellationToken` | `CancellationToken` A cancellation token to observe while waiting for the task to complete |

### WaitWithUnwrappedExceptions(Task, TimeSpan)

    public static bool WaitWithUnwrappedExceptions(this Task task, TimeSpan timeout)

Synchronously waits for the given task to complete.
Any [AggregateException](https://learn.microsoft.com/dotnet/api/system.aggregateexception) thrown is unwrapped to the first inner exception.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `task` | `Task` The task to wait for. |
| `timeout` | `TimeSpan` A TimeSpan that represents the number of milliseconds to wait, or -1 milliseconds to wait indefinitely. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |