Method StageAndCommitAsync
StageAndCommitAsync(CancellationToken)
Stages the transaction and commits the stage, for callers that have no database commit to make between the two steps.
Declaration
Task StageAndCommitAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A cancellation token that cancels the call before the transaction has been staged, or before the commit has started. |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
This is equivalent to calling StageAsync(CancellationToken) and then CommitAsync(CancellationToken) on the returned stage, and fails in the same ways.
The stage is not returned, so a commit that failed cannot be made again. When this method throws, dispose the transaction: that rolls it back, unless the commit had started and failed, in which case it leaves the transaction's files for a cleanup pass as described on CommitAsync(CancellationToken). Call the two methods separately if a failed commit is to be retried.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The transaction has already been staged, or it has been rolled back. |
| IOException | The transaction could not be staged or committed. |
| OperationCanceledException | The token was cancelled before the transaction had been staged, or before the commit had started. |
| ObjectDisposedException | The transaction has been disposed. |