Hi guys...I have ready program which often hangs when the textBox is refreshing with content.
I don't want to rewrite the code so I decided to add backgroundworker.
My Code structure is like this
private void startButton_Click(object sender, RoutedEventArgs e)
{
backgroundWorker.RunWorkerAsync();
}
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
// there are many IFs related to the options choosen in the GUI
if (option == "1")
{
LogBox.Text = "Option 1 is Starting";
option1();
}
if (option == "2")
{
LogBox.Text = "Option 2 is Starting";
option2();
}
...
}
The problem is that I receive infamous error "BackgroundWorker, Cross-thread operation not valid"
I heard that I should use delegates...Can somebody give show me some examples based on the code above?
DO I need to use delegates within option1 and option2, whenever I want to put some text into LogBox?
Thanks for help!