Reputation: 2109
I have a main thread and a child thread. The child thread is sta and updates the ui. The main thread does calculations. I am using the following code in the sta thread:
m.Dispatcher.Invoke(() =>
{
m.ProgressText.Content = newPrText;
m.ProgressBar.Value += prInc;
m.ProgressBar.Maximum = prMax;
});
The UI just freezes and hangs. It does not update the fields.
Upvotes: 0
Views: 84
Reputation: 174457
You should switch it around: Let the main thread update the UI and the child thread perform the calculations. Most likely, the controls are created on the main thread, so the dispatcher will marshal the updates back to the main thread, effectively performing all work on the main thread.
Upvotes: 4