Exemplo n.º 1
0
        AsyncCompletion GetNextCompletion()
        {
            AsyncCompletion result = this.nextAsyncCompletion;

            this.transactionContext  = null;
            this.nextAsyncCompletion = null;
            return(result);
        }
Exemplo n.º 2
0
 protected IDisposable PrepareTransactionalCall(Transaction transaction)
 {
     if (this.transactionContext != null && !this.transactionContext.IsPotentiallyAbandoned)
     {
         ThrowInvalidAsyncResult("PrepareTransactionalCall should only be called as the object of non-nested using statements. If the Begin succeeds, Check/SyncContinue must be called before another PrepareTransactionalCall.");
     }
     return(this.transactionContext = transaction == null ? null : new TransactionSignalScope(this, transaction));
 }
Exemplo n.º 3
0
        private AsyncCompletion GetNextCompletion()
        {
            AsyncCompletion nextAsyncCompletion = this.nextAsyncCompletion;

            this.transactionContext  = null;
            this.nextAsyncCompletion = null;
            return(nextAsyncCompletion);
        }
Exemplo n.º 4
0
        AsyncCompletion GetNextCompletion()
        {
            AsyncCompletion result = this.nextAsyncCompletion;

#if !WINDOWS_UWP && !PCL
            this.transactionContext = null;
#endif
            this.nextAsyncCompletion = null;
            return(result);
        }
Exemplo n.º 5
0
        private AsyncCompletion GetNextCompletion()
        {
            AsyncCompletion result = _nextAsyncCompletion;

#if NET451
            _transactionContext = null;
#endif
            _nextAsyncCompletion = null;
            return(result);
        }
Exemplo n.º 6
0
        AsyncCompletion GetNextCompletion()
        {
            AsyncCompletion result = this.nextAsyncCompletion;

#if NET451
            this.transactionContext = null;
#endif
            this.nextAsyncCompletion = null;
            return(result);
        }
Exemplo n.º 7
0
        protected override bool OnContinueAsyncCompletion(IAsyncResult result)
        {
            if (this.transactionContext != null && !this.transactionContext.Signal(result))
            {
                // The TransactionScope isn't cleaned up yet and can't be done on this thread.  Must defer
                // the callback (which is likely to attempt to commit the transaction) until later.
                return(false);
            }

            this.transactionContext = null;
            return(true);
        }
Exemplo n.º 8
0
 private void BeforePrepareAsyncCompletion()
 {
     if (this.transactionContext != null)
     {
         // It might be an old, leftover one, if an exception was thrown within the last using (PrepareTransactionalCall()) block.
         if (this.transactionContext.IsPotentiallyAbandoned)
         {
             this.transactionContext = null;
         }
         else
         {
             this.transactionContext.Prepared();
         }
     }
 }
Exemplo n.º 9
0
 protected AsyncCallback PrepareAsyncCompletion(AsyncCompletion callback)
 {
     if (this.transactionContext != null)
     {
         if (this.transactionContext.IsPotentiallyAbandoned)
         {
             this.transactionContext = null;
         }
         else
         {
             this.transactionContext.Prepared();
         }
     }
     this.nextAsyncCompletion = callback;
     if (asyncCompletionWrapperCallback == null)
     {
         asyncCompletionWrapperCallback = Fx.ThunkCallback(new AsyncCallback(AsyncResult.AsyncCompletionWrapperCallback));
     }
     return(asyncCompletionWrapperCallback);
 }
Exemplo n.º 10
0
        private bool CheckSyncValidation(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                // Once we pass the check, we know that we own forward progress, so transactionContext is correct. Verify its state.
                if (this.transactionContext != null)
                {
                    if (this.transactionContext.State != TransactionSignalState.Completed)
                    {
                        ThrowInvalidAsyncResult("Check/SyncContinue cannot be called from within the PrepareTransactionalCall using block.");
                    }
                    else if (this.transactionContext.IsSignalled)
                    {
                        // This is most likely to happen when result.CompletedSynchronously registers differently here and in the callback, which
                        // is the fault of 'result'.
                        ThrowInvalidAsyncResult(result);
                    }
                }
            }
            else if (object.ReferenceEquals(result, this.deferredTransactionalResult))
            {
                // The transactionContext may not be current if forward progress has been made via the callback. Instead,
                // use deferredTransactionalResult to see if we are supposed to execute a post-transaction callback.
                //
                // Once we pass the check, we know that we own forward progress, so transactionContext is correct. Verify its state.
                if (this.transactionContext == null || !this.transactionContext.IsSignalled)
                {
                    ThrowInvalidAsyncResult(result);
                }
                this.deferredTransactionalResult = null;
            }
            else
            {
                return(false);
            }

            this.transactionContext = null;
            return(true);
        }
Exemplo n.º 11
0
        protected AsyncCallback PrepareAsyncCompletion(AsyncCompletion callback)
        {
            if (this.transactionContext != null)
            {
                // It might be an old, leftover one, if an exception was thrown within the last using (PrepareTransactionalCall()) block.
                if (this.transactionContext.IsPotentiallyAbandoned)
                {
                    this.transactionContext = null;
                }
                else
                {
                    this.transactionContext.Prepared();
                }
            }

            this.nextAsyncCompletion = callback;
            if (AsyncResult.asyncCompletionWrapperCallback == null)
            {
                AsyncResult.asyncCompletionWrapperCallback = new AsyncCallback(AsyncCompletionWrapperCallback);
            }
            return(AsyncResult.asyncCompletionWrapperCallback);
        }
Exemplo n.º 12
0
        protected AsyncCallback PrepareAsyncCompletion(AsyncCompletion callback)
        {
#if NET451
            if (_transactionContext != null)
            {
                // It might be an old, leftover one, if an exception was thrown within the last using (PrepareTransactionalCall()) block.
                if (_transactionContext.IsPotentiallyAbandoned)
                {
                    _transactionContext = null;
                }
                else
                {
                    _transactionContext.Prepared();
                }
            }
#endif
            _nextAsyncCompletion = callback;
            if (s_asyncCompletionWrapperCallback == null)
            {
                s_asyncCompletionWrapperCallback = new AsyncCallback(AsyncCompletionWrapperCallback);
            }
            return(s_asyncCompletionWrapperCallback);
        }