private void appendText(string s) { if (_formClosing) // If form is closing, we dont want to append anymore { return; } if (InvokeRequired) { this.Invoke(new Action <string>(appendText), new object[] { s }); return; } SocketStream.AppendText(s + "\r\n"); }