Exemple #1
0
 public CompleteAsyncCodeActivityWorkItem(AsyncOperationContext asyncContext, ActivityInstance instance, IAsyncResult result)
     : base(instance)
 {
     _result       = result;
     _asyncContext = asyncContext;
     this.ExitNoPersistRequired = true;
 }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        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 Microsoft.CoreWf.Internals.FxTrace.Exception.AsError(new InvalidOperationException(SR.BeginExecuteMustNotReturnANullAsyncResult));
                }

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

                if (result.CompletedSynchronously)
                {
                    EndExecute(context, result);
                    asyncContext.CompleteOperation();
                }
                success = true;
            }
            finally
            {
                context.Dispose();
                if (!success)
                {
                    asyncContext.CancelOperation();
                }
            }
        }
Exemple #4
0
 protected CompleteData(AsyncOperationContext context, bool isCancel)
 {
     Fx.Assert(context != null, "Cannot have a null context.");
     _context  = context;
     _isCancel = isCancel;
 }
Exemple #5
0
 internal AsyncCodeActivityContext(AsyncOperationContext asyncContext, ActivityInstance instance, ActivityExecutor executor)
     : base(instance, executor)
 {
     _asyncContext = asyncContext;
 }
Exemple #6
0
 public CompleteAsyncCodeActivityData(AsyncOperationContext context, IAsyncResult result)
     : base(context, false)
 {
     _result = result;
 }