# IDurableTaskManager.CancelAsync(TaskId, string?, CancellationToken)

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

[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.
