public void RestartService(bool background)
 {
     if (!UacServiceHelper.IsAdmin())
     {
         Log.Debug("RestartService: no admin rights, use UacServiceHandler to restart service '{0}'", ServiceName);
         UacServiceHelper.RestartService(ServiceName);
     }
     else
     {
         Log.Debug("RestartService: have admin rights, restart service '{0}' ourselves", ServiceName);
         var task = Task.Factory.StartNew(() =>
         {
             try
             {
                 PerformRestart(_restartTimeout);
             }
             catch (Exception ex)
             {
                 Log.Warn(String.Format("RestartService: failed to restart service '{0}'", ServiceName), ex);
             }
         });
         if (!background)
         {
             task.Wait();
         }
     }
 }
        public void TriggerButtonClick()
        {
            if (!UacServiceHelper.IsAdmin())
            {
                Log.Debug("TriggerButtonClick: no admin rights, use UacServiceHandler for service '{0}'", ServiceName);
                switch (serviceController.Status)
                {
                case ServiceControllerStatus.Stopped:
                    UacServiceHelper.StartService(ServiceName);
                    break;

                case ServiceControllerStatus.Running:
                    UacServiceHelper.StopService(ServiceName);
                    break;
                }
            }
            else
            {
                Log.Debug("TriggerButtonClick: have admin rights, start or stop service '{0}' ourselves", ServiceName);
                switch (serviceController.Status)
                {
                case ServiceControllerStatus.Stopped:
                    serviceController.Start();
                    break;

                case ServiceControllerStatus.Running:
                    serviceController.Stop();
                    break;
                }
            }
        }