# IDurableTaskManager Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/)

## AbortAsync(TaskId, string, CancellationToken) {#abortasync-orleans-durable-tasks-taskid-string-system-threading-cancellationtoke-00f20f79}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/abortasync-orleans-durable-tasks-taskid-string-system-threading-cancellationtoke-00f20f79/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L116)

```csharp
public abstract ValueTask AbortAsync(TaskId taskId, string reason, CancellationToken cancellationToken = default(CancellationToken))
```

Administratively aborts a task of this grain: commits the task and its execution tree as failed with [DurableTaskAbortedException](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskabortedexception/) in one write, and stops their running attempts without running further task code.

### Parameters

- `taskId` (`TaskId`): The task identifier.
- `reason` (`string`): The reason for the abort, recorded as the exception message.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the abort to commit.

### Returns

An operation which completes once the abort has committed.

## AbortAsync(string, string, CancellationToken) {#abortasync-string-string-system-threading-cancellationtoken-9bcad120}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/abortasync-string-string-system-threading-cancellationtoken-9bcad120/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L116)

```csharp
public virtual ValueTask AbortAsync(string rootId, string reason, CancellationToken cancellationToken = default(CancellationToken))
```

Administratively aborts the root task `rootId` of this grain and its execution tree.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).
- `reason` (`string`): The reason for the abort, recorded as the exception message.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the abort to commit.

### Returns

An operation which completes once the abort has committed.

## CancelAsync(TaskId, string?, CancellationToken) {#cancelasync-orleans-durable-tasks-taskid-string-nullable-system-threading-cancel-3314c286}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/cancelasync-orleans-durable-tasks-taskid-string-nullable-system-threading-cancel-3314c286/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs)

```csharp
public abstract ValueTask CancelAsync(TaskId taskId, string? reason, CancellationToken cancellationToken = default(CancellationToken))
```

Durably requests cancellation of a task of this grain and its execution tree, carrying `reason`.

### Parameters

- `taskId` (`TaskId`): The task identifier.
- `reason` (`string?`): The reason which the task's [DurableTaskContext](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskcontext/) reports, or `null` for none.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the request to commit.

### Returns

An operation which completes once the cancellation request has committed and propagated.

### Exceptions

- `Orleans.Durable.Tasks.DurableTaskNotFoundException`: This grain doesn't retain the task.

## CancelAsync(TaskId, CancellationToken) {#cancelasync-orleans-durable-tasks-taskid-system-threading-cancellationtoken-d91716e3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/cancelasync-orleans-durable-tasks-taskid-system-threading-cancellationtoken-d91716e3/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L51)

```csharp
public virtual ValueTask CancelAsync(TaskId taskId, CancellationToken cancellationToken = default(CancellationToken))
```

Durably requests cancellation of a task of this grain and its execution tree.

### Parameters

- `taskId` (`TaskId`): The task identifier.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the request to commit.

### Returns

An operation which completes once the cancellation request has committed and propagated.

## CancelAsync(string, CancellationToken) {#cancelasync-string-system-threading-cancellationtoken-d63766dd}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/cancelasync-string-system-threading-cancellationtoken-d63766dd/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L77)

```csharp
public virtual ValueTask CancelAsync(string rootId, CancellationToken cancellationToken = default(CancellationToken))
```

Durably requests cancellation of the root task `rootId` of this grain and its execution tree.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the request to commit.

### Returns

An operation which completes once the cancellation request has committed and propagated.

## CancelAsync(string, string?, CancellationToken) {#cancelasync-string-string-nullable-system-threading-cancellationtoken-d3fe702b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/cancelasync-string-string-nullable-system-threading-cancellationtoken-d3fe702b/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L92)

```csharp
public virtual ValueTask CancelAsync(string rootId, string? reason, CancellationToken cancellationToken = default(CancellationToken))
```

Durably requests cancellation of the root task `rootId` of this grain and its execution tree, carrying `reason`.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).
- `reason` (`string?`): The reason which the task's [DurableTaskContext](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskcontext/) reports, or `null` for none.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the request to commit.

### Returns

An operation which completes once the cancellation request has committed and propagated.

## GetTask(TaskId) {#gettask-orleans-durable-tasks-taskid-01b74130}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/gettask-orleans-durable-tasks-taskid-01b74130/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs)

```csharp
public abstract ScheduledTask GetTask(TaskId taskId)
```

Gets a handle which observes or cancels an existing task of this grain.

### Parameters

- `taskId` (`TaskId`): The task identifier.

### Returns

A handle for the task. Polling or waiting for a task which this grain doesn't retain throws [DurableTaskNotFoundException](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletasknotfoundexception/).

## GetTask(TaskId) {#gettask-1-orleans-durable-tasks-taskid-9fab3b9c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/gettask-1-orleans-durable-tasks-taskid-9fab3b9c/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs)

```csharp
public abstract ScheduledTask<TResult> GetTask<TResult>(TaskId taskId)
```

Gets a typed handle which observes or cancels an existing task of this grain.

### Parameters

- `taskId` (`TaskId`): The task identifier.

### Returns

A handle for the task. Polling or waiting for a task which this grain doesn't retain throws [DurableTaskNotFoundException](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletasknotfoundexception/).

## GetTask(string) {#gettask-string-8fa2ea25}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/gettask-string-8fa2ea25/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs)

```csharp
public virtual ScheduledTask GetTask(string rootId)
```

Gets a handle which observes or cancels the existing root task `rootId` of this grain.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).

### Returns

A handle for the task, as [IDurableTaskManager](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/) returns.

## GetTask(string) {#gettask-1-string-007d85a9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/gettask-1-string-007d85a9/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs)

```csharp
public virtual ScheduledTask<TResult> GetTask<TResult>(string rootId)
```

Gets a typed handle which observes or cancels the existing root task `rootId` of this grain.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).

### Returns

A handle for the task, as [IDurableTaskManager](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/) returns.

## SignalAsync(TaskId, DurableSignal&lt;T&gt;, T, CancellationToken) {#signalasync-1-orleans-durable-tasks-taskid-orleans-durable-tasks-durablesignal-t-e5e659ba}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/signalasync-1-orleans-durable-tasks-taskid-orleans-durable-tasks-durablesignal-t-e5e659ba/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L147)

```csharp
public abstract ValueTask SignalAsync<T>(TaskId taskId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
```

Delivers `signal` with `value` to an invoked task of this grain.

### Parameters

- `taskId` (`TaskId`): The identifier of a task which a client or another grain invoked on this grain.
- `signal` (`DurableSignal<T>`): The signal descriptor which the task's waits share.
- `value` (`T`): The signal's value.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the signal to commit.

### Returns

An operation which completes once the signal commits with this grain's pending state changes.

### Exceptions

- `Orleans.Durable.Tasks.DurableTaskNotFoundException`: This grain retains no invoked task `taskId`.
- `System.InvalidOperationException`: The task holds a different value for the signal, or it is terminal and holds no value for the signal.

## SignalAsync(string, DurableSignal&lt;T&gt;, T, CancellationToken) {#signalasync-1-string-orleans-durable-tasks-durablesignal-t-t-system-threading-ca-e0b18af5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/signalasync-1-string-orleans-durable-tasks-durablesignal-t-t-system-threading-ca-e0b18af5/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L147)

```csharp
public virtual ValueTask SignalAsync<T>(string rootId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
```

Delivers `signal` with `value` to the invoked root task `rootId` of this grain.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).
- `signal` (`DurableSignal<T>`): The signal descriptor which the task's waits share.
- `value` (`T`): The signal's value.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the signal to commit.

### Returns

An operation which completes once the signal commits with this grain's pending state changes.

## TrySignalAsync(TaskId, DurableSignal&lt;T&gt;, T, CancellationToken) {#trysignalasync-1-orleans-durable-tasks-taskid-orleans-durable-tasks-durablesigna-e79ab2f1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/trysignalasync-1-orleans-durable-tasks-taskid-orleans-durable-tasks-durablesigna-e79ab2f1/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L180)

```csharp
public abstract ValueTask<DurableSignalResult> TrySignalAsync<T>(TaskId taskId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
```

Delivers `signal` with `value` to an invoked task of this grain, and returns how the task handled it.

### Parameters

- `taskId` (`TaskId`): The identifier of a task which a client or another grain invoked on this grain.
- `signal` (`DurableSignal<T>`): The signal descriptor which the task's waits share.
- `value` (`T`): The signal's value.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the signal to commit.

### Returns

[DurableSignalResult](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durablesignalresult/) or [DurableSignalResult](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durablesignalresult/) once the task durably holds the value, or the reason the task rejected it, which changes nothing.

## TrySignalAsync(string, DurableSignal&lt;T&gt;, T, CancellationToken) {#trysignalasync-1-string-orleans-durable-tasks-durablesignal-t-t-system-threading-2074161a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/methods/trysignalasync-1-string-orleans-durable-tasks-durablesignal-t-t-system-threading-2074161a/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/IDurableTaskManager.cs#L180)

```csharp
public virtual ValueTask<DurableSignalResult> TrySignalAsync<T>(string rootId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
```

Delivers `signal` with `value` to the invoked root task `rootId` of this grain, and returns how the task handled it.

### Parameters

- `rootId` (`string`): The root task's identifier, as passed to [TaskId](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.taskid/).
- `signal` (`DurableSignal<T>`): The signal descriptor which the task's waits share.
- `value` (`T`): The signal's value.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the signal to commit.

### Returns

The task's handling of the signal, as [IDurableTaskManager](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.idurabletaskmanager/) returns.
