private static bool HandleReserveThrottle(IAsyncResult result)
 {
     PersistenceProviderDirectory.LoadOrCreateAsyncResult asyncState = (PersistenceProviderDirectory.LoadOrCreateAsyncResult)result.AsyncState;
     asyncState.ppd.EndReserveThrottle(out asyncState.loadPending, result);
     asyncState.lockInstance = (asyncState.ppd.ConsistencyScope != DurableConsistencyScope.Local) || !asyncState.canCreateInstance;
     return(asyncState.Load());
 }
            private static void OnComplete(AsyncResult result, Exception exception)
            {
                PersistenceProviderDirectory.LoadOrCreateAsyncResult result2 = (PersistenceProviderDirectory.LoadOrCreateAsyncResult)result;
                if (result2.pipeline != null)
                {
                    result2.ppd.UnregisterPipelineInUse(result2.pipeline);
                }
                if (result2.loadPending)
                {
                    result2.ppd.throttle.Exit();
                }
                if (result2.context != null)
                {
                    lock (result2.ppd.ThisLock)
                    {
                        result2.ppd.DetachContext(result2.context, ref result2.contextsToAbort);
                        goto Label_008C;
                    }
                }
                if (result2.handle != null)
                {
                    result2.handle.Free();
                }
Label_008C:
                result2.ppd.AbortContexts(result2.contextsToAbort);
                if (exception is OperationCanceledException)
                {
                    throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new CommunicationObjectAbortedException(System.ServiceModel.Activities.SR.LoadingAborted, exception));
                }
            }
 private static bool HandleExecute(IAsyncResult result)
 {
     PersistenceProviderDirectory.LoadOrCreateAsyncResult asyncState = (PersistenceProviderDirectory.LoadOrCreateAsyncResult)result.AsyncState;
     try
     {
         asyncState.view = asyncState.ppd.store.EndExecute(result);
     }
     catch (InstanceHandleConflictException)
     {
         asyncState.view = null;
     }
     catch (InstanceLockLostException)
     {
         asyncState.view = null;
     }
     if (asyncState.view == null)
     {
         return(asyncState.ResolveHandleConflict());
     }
     if (asyncState.view.InstanceState == InstanceState.Unknown)
     {
         if (asyncState.loadAny)
         {
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InstanceNotReadyException(System.ServiceModel.Activities.SR.NoRunnableInstances));
         }
         throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.StoreViolationNoInstanceBound));
     }
     asyncState.isInstanceInitialized = asyncState.view.InstanceState != InstanceState.Uninitialized;
     return(asyncState.AfterLoad());
 }
            private static void HandleLoadRetry(object state)
            {
                PersistenceProviderDirectory.LoadOrCreateAsyncResult result = (PersistenceProviderDirectory.LoadOrCreateAsyncResult)state;
                bool      flag      = false;
                Exception exception = null;

                try
                {
                    flag = result.Load();
                }
                catch (Exception exception2)
                {
                    if (Fx.IsFatal(exception2))
                    {
                        throw;
                    }
                    exception = exception2;
                    flag      = true;
                }
                if (flag)
                {
                    result.Complete(false, exception);
                }
            }
 private static bool HandleLoadPipeline(IAsyncResult result)
 {
     PersistenceProviderDirectory.LoadOrCreateAsyncResult asyncState = (PersistenceProviderDirectory.LoadOrCreateAsyncResult)result.AsyncState;
     asyncState.pipeline.EndLoad(result);
     return(asyncState.Finish());
 }
 private static bool HandleContextEnlist(IAsyncResult result)
 {
     PersistenceProviderDirectory.LoadOrCreateAsyncResult asyncState = (PersistenceProviderDirectory.LoadOrCreateAsyncResult)result.AsyncState;
     asyncState.context.EndEnlist(result);
     return(asyncState.AddToCache());
 }
 public static PersistenceContext End(IAsyncResult result, out bool fromCache)
 {
     PersistenceProviderDirectory.LoadOrCreateAsyncResult result2 = AsyncResult.End <PersistenceProviderDirectory.LoadOrCreateAsyncResult>(result);
     fromCache = !result2.addedToCacheResult;
     return(result2.result);
 }