2using System.Threading.Tasks;
12 private readonly
bool parallel;
24 throw new ArgumentNullException(
"Array of transactions cannot be null.");
27 this.parallel = Parallel;
37 int i, c = this.transactions.Length;
38 Task<bool>[] Tasks =
new Task<bool>[c];
40 for (i = 0; i < c; i++)
41 Tasks[i] = this.transactions[i].
Prepare();
43 await Task.WhenAll(Tasks);
59 private static bool And(Task<bool>[] Tasks)
61 foreach (Task<bool> Task
in Tasks)
77 int i, c = this.transactions.Length;
78 Task<bool>[] Tasks =
new Task<bool>[c];
80 for (i = 0; i < c; i++)
81 Tasks[i] = this.transactions[i].
Execute();
83 await Task.WhenAll(Tasks);
106 int i, c = this.transactions.Length;
107 Task<bool>[] Tasks =
new Task<bool>[c];
109 for (i = 0; i < c; i++)
110 Tasks[i] = this.transactions[i].
Commit();
112 await Task.WhenAll(Tasks);
135 int i, c = this.transactions.Length;
136 Task[] Tasks =
new Task[c];
138 for (i = 0; i < c; i++)
139 Tasks[i] = this.transactions[i].
Abort();
141 await Task.WhenAll(Tasks);
A transaction built up of a set of sub-transactions.
override async Task< bool > DoCommit()
Performs actual commit.
override async Task< bool > DoPrepare()
Performs actual preparation.
override async Task< bool > DoRollback()
Performs actual rollback.
CompositeTransaction(Guid Id, bool Parallel, params ITransaction[] Transactions)
A transaction built up of a set of sub-transactions.
override async Task< bool > DoExecute()
Performs actual execution.
Abstract base class for transactions.
async Task< bool > Commit()
Commits any changes made during the execution phase.
async Task< bool > Prepare()
Prepares the transaction for execution. This step can be used for validation and authorization of the...
async Task Abort()
Aborts the transaction.
async Task< bool > Execute()
Executes the transaction.
Maintains a collection of active transactions.
Interface for transactions