Multiple Thread Woes...

Mothra

Centurion
Joined
Nov 26, 2002
Messages
173
Location
Fresno, California
Hey all,
I have form that is running a long process on a separate thread. The process runs just fine but, if a certain condition is met, I want to set an error (with the .NET ErrorProvider control) to a text box. The problem I have is that the ErrorProvider sets, the icon shows for a second and then disappears! It works just fine if run the process on the SAME thread as the UI but, since it is a long process and there's plenty other things for the user to do, I'd rather keep it separated. Any ideas as to what may be causing my ErrorProvider to "un-set"?
 
A breakpoint might help you with debugging. VS doesnt care about which thread hits the breakpoint, it breaks and gives you control over what happens next. So you can look where and how the error status is removed. Just put a breakpoint on basically every line where you use the errorprovider.

Else some code could be usefull ;).
 
When the errorprovider needs to set the error state marshal the call which will interact with the visual componant(s) back to the ui thread using form.InvokeRequired and form.Invoke, otherwise you will get unexpected and possibly wrong behavior.
 
Back
Top