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.youerw.com/jisuanji/lunwen_3170.html