Exemple #1
0
        private void btnStartStop_Click(object sender, EventArgs e)
        {
            if (btnStartStop.Text == "点击启动")
            {
                //启动服务
                btnStartStop.Text      = "点击停止";
                btnStartStop.BackColor = Color.Tomato;
                btnSetting.Enabled     = false;

                //启动服务器
                Server = new AsyncSocketServer(cfg.LocalIp, cfg.LocalPort, ClientAdd, ClientDel, Log.Info);
            }
            else
            {
                //停止服务
                btnStartStop.Text      = "点击启动";
                btnStartStop.BackColor = Color.LawnGreen;
                btnSetting.Enabled     = true;

                //关闭服务
                Server.ShutdownServer();
            }
        }