Exemplo n.º 1
0
 public static void StopService()
 {
     NetworkErrorOccured = null;
     if (listener == null || thread == null)   //service is already stopped. No problems in this case
     {
         return;
     }
     Utility.ShutdownSocket(client);
     listener.Close();
     try { thread.Join(); } catch (ThreadInterruptedException) { }
     thread   = null;
     listener = null;
     Console.WriteLine("ClipboardReceiver service CLOSED!!");
 }
        public static void StopService()
        {
            NetworkErrorOccured = null;
            if (listener == null || workerThread == null)   //service is already stopped. No problems in this case
            {
                return;
            }

            //raise the ObjectDisposedException, breaking the loop and correctly terminating the infinite events reception
            Utility.ShutdownSocket(listener);
            //listener.Close();
            try { workerThread.Join(); } catch (ThreadInterruptedException) { }
            workerThread = null;
            listener     = null;
            //client = null;
            Console.WriteLine("Mouse/Keyboard receiver service CLOSED!!");
        }