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 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); (责任编辑:qin) |