Example #1
0
 private AsyncResult.AsyncCompletion GetNextCompletion()
 {
     AsyncResult.AsyncCompletion asyncCompletion = this.nextAsyncCompletion;
     this.transactionContext  = null;
     this.nextAsyncCompletion = null;
     return(asyncCompletion);
 }
Example #2
0
 private bool TryContinueHelper(IAsyncResult result, out AsyncResult.AsyncCompletion callback)
 {
     if (result != null)
     {
         callback = null;
         if (this.checkSyncValidationFunc == null)
         {
             if (!result.CompletedSynchronously)
             {
                 return(false);
             }
         }
         else
         {
             if (!this.checkSyncValidationFunc(result))
             {
                 return(false);
             }
         }
         callback = this.GetNextCompletion();
         if (callback == null)
         {
             AsyncResult.ThrowInvalidAsyncResult("Only call Check/SyncContinue once per async operation (once per PrepareAsyncCompletion).");
         }
         return(true);
     }
     else
     {
         throw new InvalidOperationException("InvalidNullAsyncResult");                 //TODO: Fx.Exception.AsError(new InvalidOperationException(InternalSR.InvalidNullAsyncResult));
     }
 }
Example #3
0
        private static void AsyncCompletionWrapperCallback(IAsyncResult result)
        {
            if (result != null)
            {
                if (!result.CompletedSynchronously)
                {
                    AsyncResult asyncState = (AsyncResult)result.AsyncState;
                    if (asyncState.OnContinueAsyncCompletion(result))
                    {
                        AsyncResult.AsyncCompletion nextCompletion = asyncState.GetNextCompletion();
                        if (nextCompletion == null)
                        {
                            AsyncResult.ThrowInvalidAsyncResult(result);
                        }
                        bool      flag      = false;
                        Exception exception = null;
                        try
                        {
                            flag = nextCompletion(result);
                        }
                        catch (Exception exception2)
                        {
                            Exception exception1 = exception2;
                            //TODO:

                            /*if (!Fx.IsFatal(exception1))
                             * {
                             *      flag = true;
                             *      exception = exception1;
                             * }
                             * else
                             * {
                             *      throw;
                             * }
                             */
                            throw;
                        }
                        if (flag)
                        {
                            asyncState.Complete(false, exception);
                        }
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                throw new InvalidOperationException("InvalidNullAsyncResult");                 //TODO: Fx.Exception.AsError(new InvalidOperationException(InternalSR.InvalidNullAsyncResult));
            }
        }
            private bool AbandonReceiveContext(Exception operationException)
            {
                if (handleEndAbandonReceiveContext == null)
                {
                    handleEndAbandonReceiveContext = new AsyncResult.AsyncCompletion(ControlOperationInvoker.ControlOperationAsyncResult.HandleEndAbandonReceiveContext);
                }
                this.operationException = operationException;
                IAsyncResult result = this.receiveContext.BeginAbandon(TimeSpan.MaxValue, base.PrepareAsyncCompletion(handleEndAbandonReceiveContext), this);

                return(base.SyncContinue(result));
            }
Example #5
0
 protected bool SyncContinue(IAsyncResult result)
 {
     AsyncResult.AsyncCompletion asyncCompletion = null;
     if (!this.TryContinueHelper(result, out asyncCompletion))
     {
         return(false);
     }
     else
     {
         return(asyncCompletion(result));
     }
 }
Example #6
0
 protected AsyncCallback PrepareAsyncCompletion(AsyncResult.AsyncCompletion callback)
 {
     if (this.beforePrepareAsyncCompletionAction != null)
     {
         this.beforePrepareAsyncCompletionAction();
     }
     this.nextAsyncCompletion = callback;
     if (AsyncResult.asyncCompletionWrapperCallback == null)
     {
         AsyncResult.asyncCompletionWrapperCallback = new AsyncCallback(AsyncResult.AsyncCompletionWrapperCallback);                 //TODO: Fx.ThunkCallback(new AsyncCallback(AsyncResult.AsyncCompletionWrapperCallback));
     }
     return(AsyncResult.asyncCompletionWrapperCallback);
 }
        private bool ProcessReceiveContext()
        {
            if (this.receiveContext == null)
            {
                return(true);
            }
            if (handleEndProcessReceiveContext == null)
            {
                handleEndProcessReceiveContext = new AsyncResult.AsyncCompletion(WorkflowOperationContext.HandleEndProcessReceiveContext);
            }
            IAsyncResult result = ReceiveContextAsyncResult.BeginProcessReceiveContext(this, this.receiveContext, base.PrepareAsyncCompletion(handleEndProcessReceiveContext), this);

            return(base.SyncContinue(result));
        }
Example #8
0
        private static void AsyncCompletionWrapperCallback(IAsyncResult result)
        {
            if (result == null)
            {
                throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InvalidNullAsyncResult), null);
            }
            if (result.CompletedSynchronously)
            {
                return;
            }
            AsyncResult asyncState = (AsyncResult)result.AsyncState;

            if (asyncState.transactionContext != null && !asyncState.transactionContext.Signal(result))
            {
                return;
            }
            AsyncResult.AsyncCompletion nextCompletion = asyncState.GetNextCompletion();
            if (nextCompletion == null)
            {
                AsyncResult.ThrowInvalidAsyncResult(result);
            }
            bool      flag      = false;
            Exception exception = null;

            try
            {
                flag = nextCompletion(result);
            }
            catch (Exception exception2)
            {
                Exception exception1 = exception2;
                if (Fx.IsFatal(exception1))
                {
                    throw;
                }
                flag      = true;
                exception = exception1;
            }
            if (flag)
            {
                asyncState.Complete(false, exception);
            }
        }
Example #9
0
 protected AsyncCallback PrepareAsyncCompletion(AsyncResult.AsyncCompletion callback)
 {
     if (this.transactionContext != null)
     {
         if (!this.transactionContext.IsPotentiallyAbandoned)
         {
             this.transactionContext.Prepared();
         }
         else
         {
             this.transactionContext = null;
         }
     }
     this.nextAsyncCompletion = callback;
     if (AsyncResult.asyncCompletionWrapperCallback == null)
     {
         AsyncResult.asyncCompletionWrapperCallback = new AsyncCallback(AsyncResult.AsyncCompletionWrapperCallback);
     }
     return(AsyncResult.asyncCompletionWrapperCallback);
 }
Example #10
0
 private bool TryContinueHelper(IAsyncResult result, out AsyncResult.AsyncCompletion callback)
 {
     if (result == null)
     {
         throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InvalidNullAsyncResult), null);
     }
     callback = null;
     if (!result.CompletedSynchronously)
     {
         if (!object.ReferenceEquals(result, this.deferredTransactionalResult))
         {
             return(false);
         }
         if (this.transactionContext == null || !this.transactionContext.IsSignalled)
         {
             AsyncResult.ThrowInvalidAsyncResult(result);
         }
         this.deferredTransactionalResult = null;
     }
     else if (this.transactionContext != null)
     {
         if (this.transactionContext.State != AsyncResult.TransactionSignalState.Completed)
         {
             AsyncResult.ThrowInvalidAsyncResult("Check/SyncContinue cannot be called from within the PrepareTransactionalCall using block.");
         }
         else if (this.transactionContext.IsSignalled)
         {
             AsyncResult.ThrowInvalidAsyncResult(result);
         }
     }
     callback = this.GetNextCompletion();
     if (callback == null)
     {
         AsyncResult.ThrowInvalidAsyncResult("Only call Check/SyncContinue once per async operation (once per PrepareAsyncCompletion).");
     }
     return(true);
 }
 private AsyncCallback PrepareInnerAsyncCompletion(AsyncResult.AsyncCompletion innerCallback)
 {
     this.nextInnerAsyncCompletion = innerCallback;
     return base.PrepareAsyncCompletion(outermostCallback);
 }
 private AsyncResult.AsyncCompletion GetNextInnerAsyncCompletion()
 {
     AsyncResult.AsyncCompletion nextInnerAsyncCompletion = this.nextInnerAsyncCompletion;
     this.nextInnerAsyncCompletion = null;
     return nextInnerAsyncCompletion;
 }
 private bool HandleEndAcquireReference()
 {
     this.referenceAcquired = true;
     if (!this.instance.TryReleaseLastReference())
     {
         return true;
     }
     if (handleEndAbandon == null)
     {
         handleEndAbandon = new AsyncResult.AsyncCompletion(WorkflowServiceInstance.UnloadInstancePolicyHelper.UnlockAndAbortAsyncResult.HandleEndAbandon);
     }
     IAsyncResult result = this.instance.BeginAbandon(new FaultException(OperationExecutionFault.CreateAbortedFault(System.ServiceModel.Activities.SR.DefaultAbortReason)), false, this.timeoutHelper.RemainingTime(), base.PrepareAsyncCompletion(handleEndAbandon), this);
     return base.SyncContinue(result);
 }
 private bool Track()
 {
     if ((this.instance.state == WorkflowServiceInstance.State.Aborted) || !this.instance.Controller.HasPendingTrackingRecords)
     {
         return this.ReleaseLock();
     }
     if (handleEndTrack == null)
     {
         handleEndTrack = new AsyncResult.AsyncCompletion(WorkflowServiceInstance.SimpleOperationAsyncResult.HandleEndTrack);
     }
     IAsyncResult result = this.instance.Controller.BeginFlushTrackingRecords(this.instance.trackTimeout, base.PrepareAsyncCompletion(handleEndTrack), this);
     return (result.CompletedSynchronously && HandleEndTrack(result));
 }
 private bool AttachTransaction()
 {
     if ((this.OperationTransaction != null) && (this.Instance.transactionContext == null))
     {
         this.Instance.transactionContext = new TransactionContext(this.Instance, this.OperationTransaction);
         this.Instance.isInTransaction = true;
         this.Instance.isRunnable = false;
     }
     if (this.IsSynchronousOperation)
     {
         this.PerformOperation();
         return this.Track();
     }
     if (handleEndPerformOperation == null)
     {
         handleEndPerformOperation = new AsyncResult.AsyncCompletion(WorkflowServiceInstance.SimpleOperationAsyncResult.HandleEndPerformOperation);
     }
     IAsyncResult result = this.BeginPerformOperation(base.PrepareAsyncCompletion(handleEndPerformOperation), this);
     return (result.CompletedSynchronously && HandleEndPerformOperation(result));
 }
 private bool ReleasePersistenceContext()
 {
     if (this.workflowInstance.persistenceContext.State != CommunicationState.Opened)
     {
         return true;
     }
     if (onReleasePersistenceContext == null)
     {
         onReleasePersistenceContext = new AsyncResult.AsyncCompletion(WorkflowServiceInstance.ReleaseInstanceAsyncResult.OnReleasePersistenceContext);
     }
     IAsyncResult result = this.workflowInstance.persistenceContext.BeginRelease(this.workflowInstance.persistTimeout, base.PrepareAsyncCompletion(onReleasePersistenceContext), this);
     return base.SyncContinue(result);
 }
 private bool ReleaseInstance()
 {
     if (handleEndUnload == null)
     {
         handleEndUnload = new AsyncResult.AsyncCompletion(WorkflowServiceInstance.ReleaseInstanceAsyncResult.HandleEndUnload);
     }
     IAsyncResult result = null;
     try
     {
         if (this.isTryUnload)
         {
             result = this.BeginTryUnload(this.timeoutHelper.RemainingTime(), base.PrepareAsyncCompletion(handleEndUnload), this);
         }
         else
         {
             result = this.BeginUnload(this.timeoutHelper.RemainingTime(), base.PrepareAsyncCompletion(handleEndUnload), this);
         }
     }
     catch (FaultException exception)
     {
         if (!OperationExecutionFault.IsAbortedFaultException(exception))
         {
             throw;
         }
         System.ServiceModel.Activities.FxTrace.Exception.AsWarning(exception);
         return true;
     }
     return (result.CompletedSynchronously && HandleEndUnload(result));
 }
 private bool ProcessReceiveContext()
 {
     if (this.receiveContext == null)
     {
         return true;
     }
     if (handleEndProcessReceiveContext == null)
     {
         handleEndProcessReceiveContext = new AsyncResult.AsyncCompletion(WorkflowOperationContext.HandleEndProcessReceiveContext);
     }
     IAsyncResult result = ReceiveContextAsyncResult.BeginProcessReceiveContext(this, this.receiveContext, base.PrepareAsyncCompletion(handleEndProcessReceiveContext), this);
     return base.SyncContinue(result);
 }
 private bool AbandonReceiveContext(Exception operationException)
 {
     if (handleEndAbandonReceiveContext == null)
     {
         handleEndAbandonReceiveContext = new AsyncResult.AsyncCompletion(ControlOperationInvoker.ControlOperationAsyncResult.HandleEndAbandonReceiveContext);
     }
     this.operationException = operationException;
     IAsyncResult result = this.receiveContext.BeginAbandon(TimeSpan.MaxValue, base.PrepareAsyncCompletion(handleEndAbandonReceiveContext), this);
     return base.SyncContinue(result);
 }
Example #20
0
 protected bool CheckSyncContinue(IAsyncResult result)
 {
     AsyncResult.AsyncCompletion asyncCompletion = null;
     return(this.TryContinueHelper(result, out asyncCompletion));
 }
Example #21
0
 static AcceptMessageSessionAsyncResult()
 {
     AcceptMessageSessionAsyncResult.operationComplete = new AsyncResult.AsyncCompletion(AcceptMessageSessionAsyncResult.OperationComplete);
 }
 private static bool OnReleasePersistenceContext(IAsyncResult result)
 {
     WorkflowServiceInstance.ReleaseInstanceAsyncResult asyncState = (WorkflowServiceInstance.ReleaseInstanceAsyncResult) result.AsyncState;
     asyncState.workflowInstance.persistenceContext.EndRelease(result);
     if (onClosePersistenceContext == null)
     {
         onClosePersistenceContext = new AsyncResult.AsyncCompletion(WorkflowServiceInstance.ReleaseInstanceAsyncResult.OnClosePersistenceContext);
     }
     IAsyncResult result3 = asyncState.workflowInstance.persistenceContext.BeginClose(asyncState.timeoutHelper.RemainingTime(), asyncState.PrepareAsyncCompletion(onClosePersistenceContext), asyncState);
     return asyncState.SyncContinue(result3);
 }