winform 输出日志框信息
发布日期:2021-05-10 10:50:49 浏览次数:13 分类:精选文章

本文共 2503 字,大约阅读时间需要 8 分钟。

private delegate void CallbackInvokeDisplay(string msg);  
public void DebugDisplayStr(string strData)
{
if (txtAll.InvokeRequired)
{
CallbackInvokeDisplay mydel = new CallbackInvokeDisplay(DebugDisplayStr);
txtAll.Invoke(mydel, new object[] { strData });
}
else
{
if (txtAll.TextLength > 100000)
{
txtAll.Text = "";
}
txtAll.AppendText(strData);
txtAll.AppendText("\r\n");
}
}

���������������������������������`CallbackInvokeDisplay` ��������������������������� cerebration��������������� `DebugDisplayStr` ���������`DebugDisplayStr` ��������������� `txtAll` ��������������������������������� `txtAll` ��������������� `TextBox` ��������������������� GUI ������������������������������������������������:

  • ���������������

    CallbackInvokeDisplay ��������������������������� cerebration��������������� string msg ������������������������

    private delegate void CallbackInvokeDisplay(string msg);  
    ``
  • ���������������������

    DebugDisplayStr ��������������������������������������� string strData ������������������������������������������������ txtAll ���������������������������������������������������

    • ������ InvokeRequired���

      txtAll.InvokeRequired ��������� boolean ��������������������������������������������������������������������� ������ InvokeRequired ��� true��������������������������������������������������������������������� cerebration ���������������������������

    • ���������������������

      ������ InvokeRequired ��� true������������������������ mydel ��� CallbackInvokeDisplay ��������������������� DebugDisplayStr ������������������������������������ ��������������� txtAll.Invoke() ������������������������������������������������������

  • ������������������������

    ������ InvokeRequired ��� false��������������������������������������������������� txtAll ������������������������

    • ������������������

      ������ txtAll.TextLength ������ 100000������������������������ 100,000 ��������������������� txtAll.Text ������������������������

    • ���������������������

      ��� strData appending ��� txtAll ������������������������������������������ \r\n������������������������������������������

  • ��������������������������������������������������������� GUI ������������������������������������������������������������ cerebration��������������������������������������������������������������������������������������������������� threading issue���

    上一篇:C# MethodInvoker
    下一篇:C#中的委托(delegate)

    发表评论

    最新留言

    表示我来过!
    [***.240.166.169]2025年04月23日 17时24分36秒