You cannot access WinForms controls in any thread other than the user interface thread, the AKA that was created, due to problems with cross-threads, race conditions, etc. To solve this problem, you need to run any commands that you want to run in the user interface thread. This can be done using the Invoke method:
public void InvokeExample() { if (InvokeRequired) { // Invoke this method on the UI thread using an anonymous delegate Invoke(new MethodInvoker(() => InvokeExample())); return; } string header = Control.Header; }
user153498
source share