SuperSimpleTcp
SuperSimpleTcp copied to clipboard
About _Server.Stop()
Hello, why did I put _Server.Logger=PrintServeLog; Then call _Server.Stop(); Here's the code for the PrintServeLog, which outputs connection information to a ListBox.
private void PrintServeLog(string msg)
{
try
{
if (uiListBoxServe.Items.Count > 1000) uiListBoxServe.Items.Clear();
if (uiListBoxServe.InvokeRequired) // 检查我们是否与控件的线程不同
{
uiListBoxServe.Invoke(new Action(() => uiListBoxServe.Items.Insert(0, msg)));
}
else
{
uiListBoxServe.Items.Insert(0, msg);
}
}
catch (Exception ex)
{
if (uiListBoxServe.InvokeRequired) // 检查我们是否与控件的线程不同
{
uiListBoxServe.Invoke(new Action(() => uiListBoxServe.Items.Insert(0, "错误:" + ex.Message)));
}
else
{
uiListBoxServe.Items.Insert(0, "错误:" + ex.Message);
}
}
}