Exemple #1
0
        private static void StopProtocol(IServer Server)
        {
            try
            {
                Server.Stop();

                Console.WriteLine(@"服务器已关闭。");
            }
            finally
            {
                Server.Dispose();
            }
        }
Exemple #2
0
        public void Stop()
        {
            if (mService.Config.Type == "dll")
            {
                if (!mStarted)
                {
                    return;
                }

                if (mThread == null)
                {
                    return;
                }

                if (mServer == null)
                {
                    return;
                }

                mServer.Stop();
                mThread.Join();
                mStarted = false;
            }
            else
            {
                var       name        = Path.GetFileNameWithoutExtension(mService.Config.ExePath);
                Process[] localByName = Process.GetProcessesByName(name);
                if (localByName.Length > 0)
                {
                    foreach (var process in localByName)
                    {
                        process.Kill();
                        process.WaitForExit();
                    }
                }
            }
        }