示例#1
0
        private static async Task WaitForState(Func <IIS.ObjectState> getState, IIS.ObjectState state)
        {
            TimeSpan totalWait = TimeSpan.Zero;

            IIS.ObjectState?currentState;
            while ((currentState = SafeGetState(getState)) != state)
            {
                totalWait += _waitInterval;
                if (totalWait > _maxWaitInterval)
                {
                    throw new InvalidOperationException(String.Format("State unchanged after {0} seconds. Expected state: '{1}', actual state: '{2}'.",
                                                                      totalWait.TotalSeconds, state, currentState));
                }
                await Task.Delay(_waitInterval);
            }
        }
 public void VerifyAppPoolState(string appPoolName, Microsoft.Web.Administration.ObjectState state)
 {
     try
     {
         using (ServerManager serverManager = GetServerManager())
         {
             ApplicationPoolCollection appPools = serverManager.ApplicationPools;
             if (appPools[appPoolName].State == state)
             {
                 TestUtility.LogInformation(String.Format("Verified state for app pool {0} is {1}.", appPoolName, state.ToString()));
             }
             else
             {
                 TestUtility.LogInformation(String.Format("Unexpected state {0} for app pool  {1}.", state, appPoolName.ToString()));
             }
         }
     }
     catch (Exception ex)
     {
         TestUtility.LogInformation(String.Format("#################### Failed to verify state for app pool {0}. Reason: {1} ####################", appPoolName, ex.Message));
     }
 }
示例#3
0
 public static async Task WaitForState(this IIS.ApplicationPool appPool, IIS.ObjectState state)
 {
     await WaitForState(() => appPool.State, state);
 }
示例#4
0
 public static async Task WaitForState(this IIS.Site site, IIS.ObjectState state)
 {
     await WaitForState(() => site.State, state);
 }
示例#5
0
 public static void WaitForState(this IIS.Site site, IIS.ObjectState state)
 {
     new PollingWait(() => { }, () => site.State == state).Invoke();
 }
示例#6
0
 public static void WaitForState(this IIS.ApplicationPool appPool, IIS.ObjectState state)
 {
     new PollingWait(() => { }, () => appPool.State == state).Invoke();
 }