毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

HTTP服务器软件系统的设计与实现(7)

时间:2017-02-21 13:09来源:毕业论文
if (server != null) { server.Dispose(); server = null; } } private void btnStart_Click(object sender, EventArgs e) { try { /// /// 创建HTTP提供者的服务器 /// server = new WebServermyLogger(


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

        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                ///
                /// 创建HTTP提供者的服务器
                ///
                server = new WebServer<myLogger>();
                server.AddService<HttpService<myLogger>>(int.Parse(txtPort.Text));
                btnStart.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


        void Tracer_OnNewMessage(string message)
        {
            add2debug(message);
        }


        void add2debug(string message)
        {
            this.ltbDebug.Invoke((MethodInvoker)delegate
            {
                ltbDebug.Items.Add(message);
                ltbDebug.SelectedIndex = ltbDebug.Items.Count - 1;
            });
        }

        private void brnClear_Click(object sender, EventArgs e)
        {
            ltbDebug.Items.Clear();
        }
    }

    public class myLogger : IDebugger
    {
        public delegate void TraceMessageHandler(string message);
        public static event TraceMessageHandler OnNewMessage;

        public void trace(string log)
        {
            if (OnNewMessage != null)
                OnNewMessage(log); HTTP服务器软件系统的设计与实现(7):http://www.751com.cn/jisuanji/lunwen_3170.html
------分隔线----------------------------
推荐内容