# DurableTaskAttemptCanceledException

Package: [Microsoft.Orleans.Durable.Abstractions](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/) 10.0.0-alpha.1

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTaskAttemptCanceledException.cs#L57)

```csharp
[Orleans.Alias(Orleans.Durable.Tasks.DurableTaskAttemptCanceledException)]
public sealed class DurableTaskAttemptCanceledException : OperationCanceledException
```

The exception which every durable operation of a canceled attempt throws, so the attempt's code unwinds and releases its in-process resources.

## Remarks

An attempt is one in-memory run of a task's body. A host cancels the attempt, rather than the task, when the attempt's work can't be recorded any more: its grain activation is stopping, the task was aborted or deleted, or the running code can't replay the task's recorded execution, because it doesn't support a recorded version or diverged from the record. From then on, the attempt's durable operations, such as [DurableTask](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/), starting or awaiting tasks, signals, delays, and combinators, throw this exception, and the host discards the attempt's response: a stopping activation's task replays in a new attempt, and an aborted or deleted task already has its outcome. Changes which the attempt's code makes to the grain's journaled state, such as cleanup, commit with the grain's next journal write.

[DurableTaskContext](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskcontext/) and [DurableTaskContext](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskcontext/) are canceled together with the attempt. [DurableTaskContext](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskcontext/) reports only durable task cancellation, so a `catch` block filtered on it runs durable cleanup only for task cancellation. Release in-process resources, such as semaphores and disposables, in `finally` blocks and `using` statements, which run for both.

## Constructors

- [DurableTaskAttemptCanceledException](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskattemptcanceledexception/constructors/constructor-849d65f5/)
- [DurableTaskAttemptCanceledException(DurableTaskAttemptCancellationReason, CancellationToken, Exception?)](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskattemptcanceledexception/constructors/constructor-orleans-durable-tasks-durabletaskattemptcancellationreason-system-th-8d7ffb11/)
- [DurableTaskAttemptCanceledException(string?)](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskattemptcanceledexception/constructors/constructor-string-nullable-b440cbaa/)
- [DurableTaskAttemptCanceledException(string?, Exception?)](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskattemptcanceledexception/constructors/constructor-string-nullable-system-exception-nullable-7d587e6d/)
- [DurableTaskAttemptCanceledException(string?, Exception?, DurableTaskAttemptCancellationReason, CancellationToken)](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskattemptcanceledexception/constructors/constructor-string-nullable-system-exception-nullable-orleans-durable-tasks-dura-c579f7ee/)

## Properties

- [Reason](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskattemptcanceledexception/properties/reason-f10cff59/)
