コード例 #1
0
        static private bool StopOneDicomServer(DicomService service)
        {
            try
            {
                bool stopped = false;
                if (service != null)
                {
                    //if (service.Status == ServiceControllerStatus.Running || service.Status == ServiceControllerStatus.Paused)
                    if (service.Status != ServiceControllerStatus.Stopped)
                    {
                        //DateTime s = DateTime.Now;
                        //DateTime e = DateTime.Now + TimeSpan.FromSeconds(60);
                        stopped = true;


                        try
                        {
                            service.Stop();
                            service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(15));
                        }
                        catch (Exception)
                        {
                            stopped = false;
                        }

                        //while (service.Status != ServiceControllerStatus.Stopped)
                        //{
                        //   Application.DoEvents();
                        //   if (DateTime.Now > e)
                        //   {
                        //      //ShowError("Failed to stop DICOM service.");
                        //      stopped = false;
                        //      break;
                        //   }
                        //}

                        //if (!stopped)
                        //{
                        //   //ShowError("DICOM Service not uninstalled: Service Still Running");
                        //}
                    }
                    else
                    {
                        stopped = true;
                    }
                }
                return(stopped);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Assert(false, e.ToString());

                return(false);
            }
        }
コード例 #2
0
        void _serverControlStrip_StopAllServers(object sender, EventArgs e)
        {
            Gateways gateways = (Gateways)_gatewaySource.DataSource;

            foreach (Gateways.GatewayServerRow gateway in gateways.GatewayServer)
            {
                DicomService service = GetGatewayService(gateway);

                if (null != service && service.Status != ServiceControllerStatus.Stopped)
                {
                    service.Stop( );
                }
            }
        }
コード例 #3
0
        void _serverControlStrip_StopServer(object sender, EventArgs e)
        {
            DicomService gatewayService = null;

            gatewayService = GetCurrentDicomService( );

            if (gatewayService != null)
            {
                if (gatewayService.Status != ServiceControllerStatus.Stopped)
                {
                    gatewayService.Stop( );
                }
            }
        }