# ITimerRegistry Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.timers.itimerregistry/)

## RegisterGrainTimer(IGrainContext, Func&lt;TState, CancellationToken, Task&gt;, TState, GrainTimerCreationOptions) {#registergraintimer-1-orleans-runtime-igraincontext-system-func-tstate-system-thr-4f8fb3b0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.timers.itimerregistry/methods/registergraintimer-1-orleans-runtime-igraincontext-system-func-tstate-system-thr-4f8fb3b0/)

```csharp
public abstract IGrainTimer RegisterGrainTimer<TState>(IGrainContext grainContext, Func<TState, CancellationToken, Task> callback, TState state, GrainTimerCreationOptions options)
```

Creates a grain timer.

### Parameters

- `grainContext` (`IGrainContext`): The grain which the timer is associated with.
- `callback` (`Func<TState, CancellationToken, Task>`): The timer callback, which will be invoked whenever the timer becomes due.
- `state` (`TState`): The state passed to the callback.
- `options` (`GrainTimerCreationOptions`): The options for creating the timer.

### Returns

The [IGrainTimer](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraintimer/) instance which represents the timer.

## RegisterTimer(IGrainContext, Func&lt;object?, Task&gt;, object?, TimeSpan, TimeSpan) {#registertimer-orleans-runtime-igraincontext-system-func-object-nullable-system-t-d7286da5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.timers.itimerregistry/methods/registertimer-orleans-runtime-igraincontext-system-func-object-nullable-system-t-d7286da5/)

```csharp
[System.Obsolete(Use 'RegisterGrainTimer(grainContext, callback, state, new() { DueTime = dueTime, Period = period, Interleave = true })' instead.)]
public abstract IDisposable RegisterTimer(IGrainContext grainContext, Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period)
```

Creates a grain timer.

### Parameters

- `grainContext` (`IGrainContext`): The grain which the timer is associated with.
- `callback` (`Func<object?, Task>`): The timer callback, which will fire whenever the timer becomes due.
- `state` (`object?`): The state object passed to the callback.
- `dueTime` (`TimeSpan`): The amount of time to delay before the `callback` is invoked. Specify `System.Threading.Timeout.InfiniteTimeSpan` to prevent the timer from starting. Specify `System.TimeSpan.Zero` to invoke the callback promptly.
- `period` (`TimeSpan`): The time interval between invocations of `callback`. Specify `System.Threading.Timeout.InfiniteTimeSpan` to disable periodic signaling.

### Returns

An `System.IDisposable` instance which represents the timer.
