I am navigating from some window window1 to Mainwindow
In my MainWindow_loaded Method i have too much computation so when i navigate to main window windows goes white untill all computation finished and window loaded
I tried in MainWindow
private void MainWindow_Loaded_1(object sender, RoutedEventArgs e)
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (o, ea) =>
{
do large computation
};
worker.RunWorkerCompleted += (o, ea) =>
{
_busy.IsBusy = false;
};
_busy.IsBusy = true;
worker.RunWorkerAsync();
}
But problem is that it navigates to Mainwindow without computation of necessary data in loaded event handler and doesnt even show waiting bar in UI ? ?
Is it possible to show waiting bar and all computation of data in MainWindow_Loaded?
I have used ExtendedWpfToolkit for _busy which is busy indicator
You can subscribe your background worker to report progress.
And now you can have this progress report be triggered by an event you subscribe to.
In doing so, you can create a progress bar than can update itself based on this
worker_ProgressChangedevent, triggered by your computation.It appears you’ve already figured out
IsBusy, so you can have your progress bar show only when this is true.