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 leaves its files for a cleanup pass, as described on IFileRepoStagedTransaction, and on CommitAsync(CancellationToken) if the commit had started and failed. A caller that wants them discarded at once calls RollbackAsync(CancellationToken) first, which rolls the transaction back unless the commit had started. 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. |