コード例 #1
0
 public static void StopAndWaitForCompletion(this ApplicationPool applicationPool)
 {
     applicationPool.Stop();
     do
     {
         IisUtility.WaitForIisToCompleteAnyOperations();
     } while (applicationPool.State == ObjectState.Starting);
 }
コード例 #2
0
        //todo: there is quite a bit going on in here...this is going to need to be looked at...
        private void ExecuteOperation(ApplicationPool appPool, DeploymentResult result)
        {
            switch (Operation)
            {
            case Iis7Operation.StopApplicationPool:
                if (appPool == null)
                {
                    result.AddAlert(ApplicationPoolDoesNotExistError);
                }
                else if (appPool.CanBeStopped())
                {
                    CheckForElevatedPrivileges(appPool.StopAndWaitForCompletion);
                    result.AddGood("Application Pool '{0}' stopped.".FormatWith(ApplicationPool));
                }
                else
                {
                    result.AddNote("Application Pool '{0}' is not running.".FormatWith(ApplicationPool));
                }
                break;

            case Iis7Operation.StartApplicationPool:
                if (appPool == null)
                {
                    throw new InvalidOperationException(ApplicationPoolDoesNotExistError);
                }
                else if (appPool.CanBeStarted())
                {
                    IisUtility.WaitForIisToCompleteAnyOperations();
                    CheckForElevatedPrivileges(appPool.StartAndWaitForCompletion);
                    result.AddGood("Application Pool '{0}' started.".FormatWith(ApplicationPool));
                }
                else
                {
                    result.AddGood("Application Pool '{0}' is already running.".FormatWith(ApplicationPool));
                }
                break;
            }
        }