private static void StopServers()
        {
            if (stop != null)
            {
                stop.Set();
            }

            if (deviceServer != null)
            {
                deviceServer.Stop();
            }

            if (dataServer != null)
            {
                dataServer.Stop();
            }
        }
        protected override void OnStop()
        {
            var serviceStatus = new ServiceStatus();

            serviceStatus.dwCurrentState = ServiceState.SERVICE_STOP_PENDING;
            serviceStatus.dwWaitHint     = 10000;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            if (server != null)
            {
                server.Stop();
            }

            if (dataServer != null)
            {
                dataServer.Stop();
            }

            // Update the service state to Stopped.
            serviceStatus.dwCurrentState = ServiceState.SERVICE_STOPPED;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);
        }