I have a user interface which needs to be updated by a function running in a backgroundworker (a different thread from the primary one).
I would like to effectively be able to do the following without throwing an exception:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
MyProgresssbar.value = val;
MyLabel.text = "Still going...";
}
For example, could a delegate function be written that sets a component property (I don’t want to have a function for each property change).
Thanks in advance.
You should use BackgroundWorker’s built-in progress reporting functionality.
As a more general answer, you can run code in the UI thread (aynchronously) by calling