I have two windows. My mainWindow and the window with the busyIndicator. I'm using BackgroundWorker and Dispatcher to do the work (calculation and ui) in the main window, while I want to show up the busyIndicator. But only the window shows without the busyIndicator.
BusyIndicator_Window busy = new BusyIndicator_Window();
busy.Show();
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (o, ea) =>
{
Dispatcher.Invoke((Action)(() =>
{
Plot.Plot_MV.startAnke(selectedFilePath, lw);
}));
};
worker.RunWorkerCompleted += (o, ea) =>
{
busy.busyIndicator.IsBusy = false;
};
busy.busyIndicator.IsBusy = true;
worker.RunWorkerAsync();
is there anything I got wrong? Thanks
A background worker that immediately delegates back to the UI thread is pretty useless. Just do the work you want to do:
worker.DoWork += (o, ea) =>
{
Plot.Plot_MV.startAnke(selectedFilePath, lw);
};