Sometimes when you try to access UI component from a different thread, you’ll run into exception on you can’t access UI component from a different Thread than the original UI thread that creates the component.
For example, I have a Label, I would like to set the Label1.txt to some text from inside of a backgroundWorker.
Here’s some reference links:http://stackoverflow.com/questions/711408/best-way-to-invoke-any-cross-threaded-code
They come up with a very simple way of update any UI component from a different thread.
How to use:
1. Download the following code and place it inside your own project.
2. In the function where you want to update the UI component, invoke this class.
this.InvokeEx(f => f.label1.Text = "updating label ...");