Exemple #1
0
        internal sealed override void InternalExecute(System.Activities.ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
        {
            AsyncOperationContext asyncContext = executor.SetupAsyncOperationBlock(instance);

            instance.IncrementBusyCount();
            AsyncCodeActivityContext context = new AsyncCodeActivityContext(asyncContext, instance, executor);
            bool flag = false;

            try
            {
                IAsyncResult result = this.BeginExecute(context, AsyncCodeActivity.OnExecuteComplete, asyncContext);
                if (result == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.BeginExecuteMustNotReturnANullAsyncResult));
                }
                if (!object.ReferenceEquals(result.AsyncState, asyncContext))
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.BeginExecuteMustUseProvidedStateAsAsyncResultState));
                }
                if (result.CompletedSynchronously)
                {
                    ((IAsyncCodeActivity)this).FinishExecution(context, result);
                    asyncContext.CompleteOperation();
                }
                flag = true;
            }
            finally
            {
                context.Dispose();
                if (!flag)
                {
                    asyncContext.CancelOperation();
                }
            }
        }
 public CompleteAsyncCodeActivityWorkItem(AsyncOperationContext asyncContext, ActivityInstance instance, IAsyncResult result)
     : base(instance)
 {
     this.result                = result;
     this.asyncContext          = asyncContext;
     this.ExitNoPersistRequired = true;
 }
Exemple #3
0
 internal static void CompleteAsynchronousExecution(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         AsyncOperationContext asyncState = result.AsyncState as AsyncOperationContext;
         if (asyncState != null)
         {
             asyncState.CompleteAsyncCodeActivity(new CompleteAsyncCodeActivityData(asyncState, result));
         }
     }
 }
        internal static void CompleteAsynchronousExecution(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                return;
            }
            AsyncOperationContext asyncContext = result.AsyncState as AsyncOperationContext;

            // User code may not have correctly passed the AsyncOperationContext thru as the "state" parameter for
            // BeginInvoke. If is null, don't bother going any further. We would have thrown an exception out of the
            // workflow from InternalExecute. In that case, AsyncOperationContext.CancelOperation will be called in
            // InternalExecute.
            if (asyncContext != null)
            {
                asyncContext.CompleteAsyncCodeActivity(new CompleteAsyncCodeActivityData(asyncContext, result));
            }
        }
        sealed internal override void InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
        {
            // first set up an async context
            AsyncOperationContext asyncContext = executor.SetupAsyncOperationBlock(instance);

            instance.IncrementBusyCount();

            AsyncCodeActivityContext context = new AsyncCodeActivityContext(asyncContext, instance, executor);
            bool success = false;

            try
            {
                IAsyncResult result = BeginExecute(context, AsyncCodeActivity.OnExecuteComplete, asyncContext);

                if (result == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.BeginExecuteMustNotReturnANullAsyncResult));
                }

                if (!object.ReferenceEquals(result.AsyncState, asyncContext))
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.BeginExecuteMustUseProvidedStateAsAsyncResultState));
                }

                if (result.CompletedSynchronously)
                {
                    EndExecute(context, result);
                    asyncContext.CompleteOperation();
                }
                success = true;
            }
            finally
            {
                context.Dispose();
                if (!success)
                {
                    asyncContext.CancelOperation();
                }
            }
        }
 internal AsyncCodeActivityContext(AsyncOperationContext asyncContext, System.Activities.ActivityInstance instance, ActivityExecutor executor) : base(instance, executor)
 {
     this.asyncContext = asyncContext;
 }
 protected CompleteData(AsyncOperationContext context, bool isCancel)
 {
     Fx.Assert(context != null, "Cannot have a null context.");
     this.context = context;
     this.isCancel = isCancel;
 }
 public CompleteAsyncCodeActivityWorkItem(AsyncOperationContext asyncContext, ActivityInstance instance, IAsyncResult result)
     : base(instance)
 {
     this.result = result;
     this.asyncContext = asyncContext;
     this.ExitNoPersistRequired = true;
 }
 public CompleteAsyncCodeActivityData(AsyncOperationContext context, IAsyncResult result)
     : base(context, false)
 {
     this.result = result;
 }
 public CompleteAsyncCodeActivityData(AsyncOperationContext context, IAsyncResult result)
     : base(context, false)
 {
     this.result = result;
 }
 protected CompleteData(AsyncOperationContext context, bool isCancel)
 {
     Fx.Assert(context != null, "Cannot have a null context.");
     this.context  = context;
     this.isCancel = isCancel;
 }
 protected CompleteData(AsyncOperationContext context, bool isCancel)
 {
     this.context = context;
     this.isCancel = isCancel;
 }
 internal AsyncCodeActivityContext(AsyncOperationContext asyncContext, ActivityInstance instance, ActivityExecutor executor)
     : base(instance, executor)
 {
     this.asyncContext = asyncContext;
 }
Exemple #14
0
 protected CompleteData(AsyncOperationContext context, bool isCancel)
 {
     this.context  = context;
     this.isCancel = isCancel;
 }