Esempio n. 1
0
 protected bool StopService()
 {
     try
     {
         if (ServiceRunning())
         {
             _windowsServiceMonitor.Stop();
             InitialServiceStatus();
             MessageBox.Show("关闭采集服务成功!");
             return(true);
         }
         else
         {
             InitialServiceStatus();
             return(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
         return(false);
     }
 }
Esempio n. 2
0
        private async Task ChangeServiceStatus(object context)
        {
            ReadyToChange = false;
            try
            {
                if (_serviceMonitor.IsRunning)
                {
                    await _serviceMonitor.Stop();
                }
                else
                {
                    await _serviceMonitor.Start();
                }
            }
            catch (Exception ex)
            {
                ReadyToChange = true;
                throw new Exception("Could not do that", ex);
                // UserMessages.Text = ex.InnerException.Message;
            }

            Running = _serviceMonitor.IsRunning;
            ReadyToChange = true;
        }