public void printMessage(string message)
{
try
{
if (this.InvokeRequired)
{
try
{
this.Invoke(new WriteLineHandler(printMessage), new object[] { message });
}
catch (Exception)
{
}
}
else
{
if (message.Length > 0)
{
StringBuilder sb = new StringBuilder();
sb.Append(DateTime.Now.ToString("G"));
sb.Append(": ");
sb.Append(message);
sb.Append("\n");
sb.Append(richTextBox.Text);
richTextBox.Text = sb.ToString();
}
}
}
catch (Exception)
{
}
}
this.Invoke(new WriteLineHandler(printMessage), new object[] { message });
这条线需要很长时间才能执行。任何人都可以帮助我提高性能。