SuperSimpleTcp icon indicating copy to clipboard operation
SuperSimpleTcp copied to clipboard

About _Server.Stop()

Open FreeVB opened this issue 7 months ago • 5 comments

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);
        }
    }
}

FreeVB avatar Nov 18 '23 00:11 FreeVB