In my application I used to add a lot of text in Richtextbox. It takes a lot of time, so i have added a progress bar. I need to close that as soon as GUI is updated. Is there is any to to catch after GUI is updated. I have tried with App.Current.MainWindow.IsLoaded == true, but it seems even the gui is not updated, but MainWindow.IsLoaded property is true for main window.
Herewith the code for the same.
private void OnWorkerMethodstart()
{
pbw = new ProgressBarWindow();
pbw.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
pbw.ShowDialog();
}
));
}
private void OnWorkerMethodStart()
{
ThreadStart tStart = new ThreadStart(OnWorkerMethodstart);
t = new Thread(tStart);
t.SetApartmentState(ApartmentState.STA);
t.Start();
this.OpenW();
BackgroundWorker _BackgroundWorker1 = new BackgroundWorker();
_BackgroundWorker1.DoWork += new DoWorkEventHandler(
delegate(object o, DoWorkEventArgs args)
{
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
DateTime da = DateTime.Now.AddMinutes(30);
MainWindow mw;
while (DateTime.Now != da)
{
mw = new MainWindow();
//if (mw.Editor.Workflow.Steps.Count > 1)
if (App.Current.MainWindow.IsLoaded == true)
{
t.Abort();
break;
}
else
{
//Thread.Sleep(1000);
}
mw = null;
}
}
));
});
_BackgroundWorker1.RunWorkerAsync();
}