Exemplo n.º 1
0
 public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)
 {
     InTask(async() =>
     {
         try
         {
             using (var cts = CommitCancellationScope())
                 await(await EnlistedUnitOfWork.Prepare(cts.Token).ConfigureAwait(false)).Commit(cts.Token).ConfigureAwait(false);
         }
         catch
         {
             singlePhaseEnlistment.Aborted();
             throw;
         }
         singlePhaseEnlistment.Committed();
     });
 }
Exemplo n.º 2
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     InTask(async() =>
     {
         ITransactionReady rdy = null;
         try
         {
             using (var cts = PrepareCancellationScope())
                 rdy = await EnlistedUnitOfWork.Prepare(cts.Token).ConfigureAwait(false);
         }
         catch (Exception ex)
         {
             CompletedError(ex);
             preparingEnlistment.ForceRollback(ex);
             throw;
         }
         Ready = rdy;
     });
     preparingEnlistment.Prepared();
 }
Exemplo n.º 3
0
 public void Rollback(Enlistment enlistment)
 {
     if (Ready == null) // Just dispose without any action
     {
         EnlistedUnitOfWork.Dispose();
     }
     else
     {
         InTask(async() =>
         {
             try
             {
                 using (var cts = RollbackCancellationScope())
                     await Ready.Rollback(cts.Token).ConfigureAwait(false);
             }
             catch (Exception ex)
             {
                 CompletedError(ex);
                 throw;
             }
         });
     }
     enlistment.Done();
 }