void Log(string message) { var newDebugText = string.Format("{0}{1}", message, Environment.NewLine); if(textDebug.InvokeRequired) { var d = new SetDebugTextCallback(SetDebugText); Invoke(d, newDebugText); } else { SetDebugText(newDebugText); } }
private void SetDebugText(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.DebugText.InvokeRequired) { SetDebugTextCallback d = new SetDebugTextCallback(SetDebugText); this.Invoke(d, new object[] { text }); } else { this.DebugText.Text = text; } }