I’m practising on threading and came across this problem. The situation is like this:
-
I have 4 progress bars on a single form, one for downloading a file, one for showing the page loading status etc…
-
I have to control the progress of each ProgressBar from a separate thread.
The problem is I’m getting an InvalidOperationException which says
Cross-thread operation not valid: Control ‘progressBar1’ accessed from
a thread other than the thread it was created on.
Am I wrong in this approach or can anybody tell me how to implement this?
The UI elements can only be accessed by the UI thread. WinForms and WPF/Silverlight doesn’t allow access to controls from multiple threads.
A work-around to this limitation can be found here.