public GetInstanceAsyncResult(DurableInstanceManager instanceManager, InstanceKey instanceKey, ICollection<InstanceKey> additionalKeys, WorkflowGetInstanceContext parameters, TimeSpan timeout, AsyncCallback callback, object state) : this(instanceManager, parameters, timeout, callback, state)
 {
     this.instanceKey = instanceKey;
     this.additionalKeys = additionalKeys;
     if (this.GetInstance())
     {
         base.Complete(true);
     }
 }
            bool Process()
            {
                EnsureInstanceIdAndIdentity();

                this.getInstanceContext = new WorkflowGetInstanceContext
                {
                    WorkflowHostingEndpoint = this.invoker.endpoint as WorkflowHostingEndpoint,
                    CanCreateInstance = this.invoker.CanCreateInstance,
                    Inputs = this.inputs,
                    OperationContext = this.operationContext,
                };

                IAsyncResult result;

                bool shouldAbandon = true;
                try
                {
                    try
                    {
                        if (!this.invoker.isControlOperation && this.instanceKey != null && this.instanceKey.IsValid)
                        {
                            result = this.invoker.instanceManager.BeginGetInstance(this.instanceKey, this.additionalKeys, this.getInstanceContext,
                                this.invoker.persistTimeout, this.PrepareAsyncCompletion(handleEndGetInstance), this);
                        }
                        else
                        {
                            result = this.invoker.instanceManager.BeginGetInstance(this.instanceId, this.getInstanceContext, this.updatedIdentity,
                                this.invoker.persistTimeout, this.PrepareAsyncCompletion(handleEndGetInstance), this);
                        }
                        shouldAbandon = false;
                    }
                    catch (InstanceLockedException exception)
                    {
                        RedirectionException redirectionException;
                        if (TryCreateRedirectionException(exception, out redirectionException))
                        {
                            throw FxTrace.Exception.AsError(redirectionException);
                        }
                        throw FxTrace.Exception.AsError(CreateFaultException(exception));
                    }
                    catch (OperationCanceledException exception)
                    {
                        BufferReceiveHelper(ref shouldAbandon, true);
                        throw FxTrace.Exception.AsError(new RetryException(null, exception));
                    }
                    catch (InstancePersistenceException exception)
                    {
                        BufferReceiveHelper(ref shouldAbandon, false);

                        if (exception is InstanceKeyNotReadyException)
                        {
                            this.invoker.host.RaiseUnknownMessageReceived(this.operationContext.IncomingMessage);
                        }

                        this.invoker.host.FaultServiceHostIfNecessary(exception);

                        throw FxTrace.Exception.AsError(CreateFaultException(exception));
                    }
                    catch (InstanceUpdateException)
                    {
                        throw FxTrace.Exception.AsError(new FaultException(OperationExecutionFault.CreateUpdateFailedFault(
                            SR.WorkflowInstanceUpdateFailed(this.instanceId, this.updatedIdentity.Identity))));
                    }
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    if (!shouldAbandon || !ShouldAbandonReceiveContext())
                    {
                        throw;
                    }
                    return AbandonReceiveContext(exception);
                }

                if (result.CompletedSynchronously)
                {
                    return HandleEndGetInstance(result);
                }
                return false;
            }
 public GetInstanceAsyncResult(DurableInstanceManager instanceManager, Guid instanceId, WorkflowGetInstanceContext parameters, TimeSpan timeout, AsyncCallback callback, object state) : this(instanceManager, parameters, timeout, callback, state)
 {
     this.instanceId = instanceId;
     if (this.GetInstance())
     {
         base.Complete(true);
     }
 }
 private GetInstanceAsyncResult(DurableInstanceManager instanceManager, WorkflowGetInstanceContext parameters, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.instanceManager = instanceManager;
     this.parameters = parameters;
     this.timeout = timeout;
     this.loadAny = parameters == null;
     base.OnCompleting = onCompleting;
     Transaction current = Transaction.Current;
     if ((current == null) && this.instanceManager.Host.IsLoadTransactionRequired)
     {
         this.committableTransaction = new CommittableTransaction(this.timeout);
         current = this.committableTransaction;
     }
     if (current != null)
     {
         this.transaction = current.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
     }
 }
 internal IAsyncResult BeginGetInstance(InstanceKey instanceKey, ICollection<InstanceKey> additionalKeys, WorkflowGetInstanceContext parameters, TimeSpan timeout, AsyncCallback callback, object state)
 {
     ThrowIfClosedOrAborted(this.state);
     return new GetInstanceAsyncResult(this, instanceKey, additionalKeys, parameters, timeout, callback, state);
 }
 internal IAsyncResult BeginGetInstance(Guid instanceId, WorkflowGetInstanceContext parameters, TimeSpan timeout, AsyncCallback callback, object state)
 {
     ThrowIfClosedOrAborted(this.state);
     return new GetInstanceAsyncResult(this, instanceId, parameters, timeout, callback, state);
 }
 private bool Process()
 {
     IAsyncResult result;
     this.EnsureInstanceId();
     WorkflowGetInstanceContext context = new WorkflowGetInstanceContext {
         WorkflowHostingEndpoint = this.invoker.endpoint as WorkflowHostingEndpoint,
         CanCreateInstance = this.invoker.CanCreateInstance,
         Inputs = this.inputs,
         OperationContext = this.operationContext
     };
     this.getInstanceContext = context;
     bool shouldAbandon = true;
     try
     {
         try
         {
             if ((!this.invoker.isControlOperation && (this.instanceKey != null)) && this.instanceKey.IsValid)
             {
                 result = this.invoker.instanceManager.BeginGetInstance(this.instanceKey, this.additionalKeys, this.getInstanceContext, this.invoker.persistTimeout, base.PrepareAsyncCompletion(handleEndGetInstance), this);
             }
             else
             {
                 result = this.invoker.instanceManager.BeginGetInstance(this.instanceId, this.getInstanceContext, this.invoker.persistTimeout, base.PrepareAsyncCompletion(handleEndGetInstance), this);
             }
             shouldAbandon = false;
         }
         catch (InstanceLockedException exception)
         {
             RedirectionException exception2;
             if (this.TryCreateRedirectionException(exception, out exception2))
             {
                 throw System.ServiceModel.Activities.FxTrace.Exception.AsError(exception2);
             }
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(CreateFaultException(exception));
         }
         catch (OperationCanceledException exception3)
         {
             this.BufferReceiveHelper(ref shouldAbandon, true);
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new RetryException(null, exception3));
         }
         catch (InstancePersistenceException exception4)
         {
             this.BufferReceiveHelper(ref shouldAbandon, false);
             if (exception4 is InstanceKeyNotReadyException)
             {
                 this.invoker.host.RaiseUnknownMessageReceived(this.operationContext.IncomingMessage);
             }
             this.invoker.host.FaultServiceHostIfNecessary(exception4);
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(CreateFaultException(exception4));
         }
     }
     catch (Exception exception5)
     {
         if (Fx.IsFatal(exception5))
         {
             throw;
         }
         if (!shouldAbandon || !this.ShouldAbandonReceiveContext())
         {
             throw;
         }
         return this.AbandonReceiveContext(exception5);
     }
     return (result.CompletedSynchronously && HandleEndGetInstance(result));
 }