if (textBox1.InvokeRequired) { textBox1.Invoke(new MethodInvoker(delegate { textBox1.AppendText(sb.ToString()); })); }