You are accessing the textbox in the thread you have created. You are doing this in your
method. This is not allowed.
You are only getting this error while debugging because illegal cross thread calls are only checked if debugger is attached. Here is the relevant part of code from MSDN
] (Line 300).
private static bool checkForIllegalCrossThreadCalls = Debugger.IsAttached;
You should take a look at
. It may help you achieve what you are trying to do here.