# ICosmosOperationExecutor.ExecuteOperation(Func&lt;TArg, Task&lt;TResult&gt;&gt;, TArg, CancellationToken)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.persistence.cosmos.icosmosoperationexecutor/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.persistence.cosmos.icosmosoperationexecutor/methods/)

[Source](https://github.com/dotnet/orleans/blob/fbe240c34e9a1389ca5ab2d52f292ed8749ea530/src/Azure/Shared/Cosmos/CosmosOptions.cs#L159-L160)

```csharp
public virtual Task<TResult> ExecuteOperation<TArg, TResult>(Func<TArg, Task<TResult>> func, TArg arg, CancellationToken cancellationToken)
```

Executes the provided Cosmos DB operation with cancellation.

### Parameters

- `func` (`Func<TArg, Task<TResult>>`): The delegate to execute.
- `arg` (`TArg`): The argument to pass to delegate invocations.
- `cancellationToken` (`CancellationToken`): The token used to cancel the operation and retry waits.

### Returns

The result of invoking the delegate.
