# Interface IScheduler (4.10.0)

<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.IScheduler)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.IScheduler)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.IScheduler)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.IScheduler)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.IScheduler)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.IScheduler)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.IScheduler)

    public interface IScheduler

Abstraction of scheduler-like operations, used for testability.

## Namespace

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

## Assembly

Google.Api.Gax.dll

## Remarks

Note that this is different to [TaskScheduler](https://learn.microsoft.com/dotnet/api/system.threading.tasks.taskscheduler), which is really involved
with assigning tasks to threads rather than any sort of delay.

## Methods

### Delay(TimeSpan, CancellationToken)

    Task Delay(TimeSpan delay, CancellationToken cancellationToken)

Returns a task which will complete after the given delay. Whether the returned
awaitable is configured to capture the current context or not is implementation-specific.
(A test implementation may capture the current context to enable reliable testing.)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `delay` | `https://learn.microsoft.com/dotnet/api/system.timespan` Time to delay for. Must not be negative. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The cancellation token that will be checked prior to completing the returned task. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task which will complete after the given delay. |

## Extension Method

[SchedulerExtensions.Sleep(IScheduler, TimeSpan, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.SchedulerExtensions#Google_Api_Gax_SchedulerExtensions_Sleep_Google_Api_Gax_IScheduler_System_TimeSpan_System_Threading_CancellationToken_)