private static bool HandleEndExecute(IAsyncResult result)
 {
     PersistenceContext.SaveAsyncResult asyncState = (PersistenceContext.SaveAsyncResult)result.AsyncState;
     asyncState.persistenceContext.store.EndExecute(result);
     asyncState.persistenceContext.IsCompleted = asyncState.saveStatus == SaveStatus.Completed;
     asyncState.persistenceContext.IsLocked    = asyncState.saveStatus == SaveStatus.Locked;
     return(asyncState.AfterSave());
 }
 private static bool HandleEndEnlist(IAsyncResult result)
 {
     PersistenceContext.SaveAsyncResult asyncState = (PersistenceContext.SaveAsyncResult)result.AsyncState;
     asyncState.persistenceContext.EndEnlist(result);
     if (!asyncState.persistenceContext.ScheduleDetach())
     {
         asyncState.persistenceContext.directory.RemoveInstance(asyncState.persistenceContext);
     }
     return(asyncState.AfterEnlist());
 }