// Token: 0x0600081B RID: 2075 RVA: 0x00027510 File Offset: 0x00025710
        internal static bool SleepUntilShutdown(TimeSpan ts, bool throwIfShuttingdown)
        {
            bool flag = AmHelper.SleepUntilShutdown(ts);

            if (flag && throwIfShuttingdown)
            {
                throw new AmServiceShuttingDownException();
            }
            return(flag);
        }
 // Token: 0x0600005B RID: 91 RVA: 0x00002E33 File Offset: 0x00001033
 protected void DelayFirstStartup()
 {
     if (AmStartupAutoMounter.sm_isFirstTimeStartupMount)
     {
         AmStartupAutoMounter.sm_isFirstTimeStartupMount = false;
         AmHelper.SleepUntilShutdown(TimeSpan.FromMilliseconds((double)RegistryParameters.AutoMounterFirstStartupDelayInMsec), true);
     }
     if (AmSystemManager.Instance.StoreStateMarker != null)
     {
         AmSystemManager.Instance.StoreStateMarker.ClearAllStoreStartRequests();
     }
 }
        // Token: 0x06000495 RID: 1173 RVA: 0x00018778 File Offset: 0x00016978
        internal static void Mount(Guid mdbGuid, MountFlags flags)
        {
            bool flag = false;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(null))
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                bool isCheckDbStatus = true;
                bool flag2           = false;
                for (;;)
                {
                    ReplayCrimsonEvents.MountStoreRpcInitiated.Log <Guid, MountFlags>(mdbGuid, flags);
                    Exception ex = null;
                    try
                    {
                        try
                        {
                            newStoreControllerInstance.MountDatabase(Guid.Empty, mdbGuid, (int)flags);
                            AmTrace.Info("rpcAdmin.MountDatabase({0}) successful.", new object[]
                            {
                                mdbGuid
                            });
                            isCheckDbStatus = false;
                            flag2           = true;
                            break;
                        }
                        catch (MapiExceptionMountInProgress mapiExceptionMountInProgress)
                        {
                            ex = mapiExceptionMountInProgress;
                            AmTrace.Error("rpcAdmin.MountDatabase({0}) encountered {1}.", new object[]
                            {
                                mdbGuid,
                                mapiExceptionMountInProgress.Message
                            });
                            if (!flag)
                            {
                                ReplayCrimsonEvents.MountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, mapiExceptionMountInProgress.Message);
                                flag = true;
                            }
                            if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                            {
                                throw;
                            }
                            if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                            {
                                AmTrace.Debug("shutdown requested - hence not retrying mount for database {0}", new object[]
                                {
                                    mdbGuid
                                });
                                throw;
                            }
                        }
                        catch (MapiPermanentException ex2)
                        {
                            ex = ex2;
                            throw;
                        }
                        catch (MapiRetryableException ex3)
                        {
                            ex = ex3;
                            throw;
                        }
                        continue;
                    }
                    finally
                    {
                        if (flag2)
                        {
                            ReplayCrimsonEvents.MountStoreRpcSucceeded.Log <Guid>(mdbGuid);
                        }
                        else if (ex == null || !(ex is MapiExceptionMountInProgress))
                        {
                            ReplayCrimsonEvents.MountStoreRpcFailed.Log <Guid, string, Exception>(mdbGuid, (ex != null) ? ex.Message : null, ex);
                        }
                        AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, flag2, isCheckDbStatus);
                    }
                    break;
                }
            }
        }
        // Token: 0x06000498 RID: 1176 RVA: 0x000189B0 File Offset: 0x00016BB0
        internal static void RemoteDismount(AmServerName serverName, Guid mdbGuid, UnmountFlags flags, bool retryOnConflict)
        {
            bool      isCheckDbStatus = true;
            bool      isMounted       = true;
            Exception ex = null;

            try
            {
                AmTrace.Debug("RemoteDismount() starting for DB {0} on server {1}. UnmountFlags = {2}, retryOnConflict = {3}", new object[]
                {
                    mdbGuid,
                    serverName,
                    flags,
                    retryOnConflict
                });
                ReplayCrimsonEvents.DismountStoreRpcInitiated.Log <AmServerName, Guid, UnmountFlags, bool>(serverName, mdbGuid, flags, retryOnConflict);
                using (IStoreMountDismount storeMountDismountInstance = Dependencies.GetStoreMountDismountInstance(AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn))
                {
                    if (!retryOnConflict)
                    {
                        storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                        isCheckDbStatus = false;
                        isMounted       = false;
                        AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                        {
                            mdbGuid
                        });
                    }
                    else
                    {
                        bool      flag      = false;
                        Stopwatch stopwatch = new Stopwatch();
                        stopwatch.Start();
                        for (;;)
                        {
                            try
                            {
                                storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                                isCheckDbStatus = false;
                                isMounted       = false;
                                AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                                {
                                    mdbGuid
                                });
                            }
                            catch (MapiRetryableException ex2)
                            {
                                AmTrace.Error("rpcAdmin.UnmountDatabase({0}) encountered {1}.", new object[]
                                {
                                    mdbGuid,
                                    ex2.Message
                                });
                                if (!(ex2 is MapiExceptionDismountInProgress))
                                {
                                    throw;
                                }
                                if (!flag)
                                {
                                    ReplayCrimsonEvents.DismountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, ex2.Message);
                                    flag = true;
                                }
                                if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                                {
                                    throw;
                                }
                                if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                                {
                                    AmTrace.Debug("shutdown requested - hence not retrying dismount for database {0}", new object[]
                                    {
                                        mdbGuid
                                    });
                                    throw;
                                }
                                continue;
                            }
                            break;
                        }
                    }
                }
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex3.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex3))
                {
                    throw;
                }
            }
            catch (MapiRetryableException ex4)
            {
                ex = ex4;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex4.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex4))
                {
                    throw;
                }
            }
            finally
            {
                ReplayCrimsonEvents.DismountStoreRpcFinished.Log <AmServerName, Guid, string>(serverName, mdbGuid, (ex != null) ? ex.Message : "<none>");
                if (AmServerName.IsNullOrEmpty(serverName) || AmServerName.IsEqual(AmServerName.LocalComputerName, serverName))
                {
                    AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, isMounted, isCheckDbStatus);
                }
            }
        }