# DurableTaskReference&lt;TResult&gt; Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/)

## AbortAsync(string, CancellationToken) {#abortasync-string-system-threading-cancellationtoken-6ab5228d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/abortasync-string-system-threading-cancellationtoken-6ab5228d/)

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

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

Administratively aborts the task, which terminalizes it and its execution tree as failed with [DurableTaskAbortedException](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskabortedexception/) without running further task code.

### Parameters

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

## CancelAsync(CancellationToken) {#cancelasync-system-threading-cancellationtoken-bbae8534}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/cancelasync-system-threading-cancellationtoken-bbae8534/)

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

```csharp
public ValueTask CancelAsync(CancellationToken cancellationToken = default(CancellationToken))
```

Requests durable cancellation of the task.

### Parameters

- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the request to commit.

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

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

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

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

Requests durable cancellation of the task carrying `reason`.

### Parameters

- `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. The first request determines the reason.
- `cancellationToken` (`CancellationToken`): A token which abandons waiting for the request to commit.

## GetResponseAsync(CancellationToken) {#getresponseasync-system-threading-cancellationtoken-b3bea991}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/getresponseasync-system-threading-cancellationtoken-b3bea991/)

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

```csharp
public Task<DurableTaskResponse> GetResponseAsync(CancellationToken cancellationToken = default(CancellationToken))
```

Waits for the task's terminal response.

### Parameters

- `cancellationToken` (`CancellationToken`): A token which abandons the wait. It doesn't cancel the task.

### Exceptions

- `Orleans.Durable.Tasks.DurableTaskNotFoundException`: The grain retains no task with this identifier.

## GetResponseAsync(PollingOptions, CancellationToken) {#getresponseasync-orleans-durable-tasks-pollingoptions-system-threading-cancellat-3d29b966}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/getresponseasync-orleans-durable-tasks-pollingoptions-system-threading-cancellat-3d29b966/)

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

```csharp
public Task<DurableTaskResponse> GetResponseAsync(PollingOptions options, CancellationToken cancellationToken = default(CancellationToken))
```

Waits for the task's terminal response, polling with `options`.

### Parameters

- `options` (`PollingOptions`): The options of each poll.
- `cancellationToken` (`CancellationToken`): A token which abandons the wait. It doesn't cancel the task.

### Exceptions

- `Orleans.Durable.Tasks.DurableTaskNotFoundException`: The grain retains no task with this identifier.

## GetStatusAsync(PollingOptions, CancellationToken) {#getstatusasync-orleans-durable-tasks-pollingoptions-system-threading-cancellatio-2a8395d8}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/getstatusasync-orleans-durable-tasks-pollingoptions-system-threading-cancellatio-2a8395d8/)

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

```csharp
public Task<DurableTaskStatus> GetStatusAsync(PollingOptions options = default(PollingOptions), CancellationToken cancellationToken = default(CancellationToken))
```

Polls the task and returns its current status.

### Parameters

- `options` (`PollingOptions`): The options of the poll.
- `cancellationToken` (`CancellationToken`): A token which abandons the poll.

### Exceptions

- `Orleans.Durable.Tasks.DurableTaskNotFoundException`: The grain retains no task with this identifier.

## IsCompletedAsync(PollingOptions, CancellationToken) {#iscompletedasync-orleans-durable-tasks-pollingoptions-system-threading-cancellat-171cd1ef}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/iscompletedasync-orleans-durable-tasks-pollingoptions-system-threading-cancellat-171cd1ef/)

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

```csharp
public Task<bool> IsCompletedAsync(PollingOptions options = default(PollingOptions), CancellationToken cancellationToken = default(CancellationToken))
```

Polls the task and returns whether it is terminal.

### Parameters

- `options` (`PollingOptions`): The options of the poll.
- `cancellationToken` (`CancellationToken`): A token which abandons the poll.

### Exceptions

- `Orleans.Durable.Tasks.DurableTaskNotFoundException`: The grain retains no task with this identifier.

## RunAsync(DurableTaskContext) {#runasync-orleans-durable-tasks-durabletaskcontext-abcaba85}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/runasync-orleans-durable-tasks-durabletaskcontext-abcaba85/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/DurableTaskReference.cs#L127-L128)

```csharp
protected internal override ValueTask<DurableTaskResponse> RunAsync(DurableTaskContext context)
```

Runs the definition in the supplied execution context.

### Parameters

- `context` (`DurableTaskContext`)

## WaitAsync(CancellationToken) {#waitasync-system-threading-cancellationtoken-549e4d80}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskreference-1/methods/waitasync-system-threading-cancellationtoken-549e4d80/)

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

```csharp
public ConfiguredScheduledTaskAwaitable<TResult> WaitAsync(CancellationToken cancellationToken = default(CancellationToken))
```

Waits for the task's successful result.

### Parameters

- `cancellationToken` (`CancellationToken`): A token which abandons the wait. It doesn't cancel the task.

### Returns

An awaitable which returns the result, or throws the task's failure or cancellation.
