I want to show the animated progressbar while saving view
the above code is the one I'm experimenting on but it gives me an error saying:
" The calling thread must be STA, because many UI components require this."
The error appears on the constructor of the Page i'm loading.
I have no idea now what to do. Is there any way I can make this simpler as this is my frist time to use BackgroundWorker..
private void OnScreenShotAllCommandExecuted(object parameter) { UserControl view = new UserControl();
view.Show(); SaveAllScreen saveScerrn = new SaveAllScreen(); worker.RunWorkerAsync(saveScerrn); } private void worker_DoWork(object sender, DoWorkEventArgs e) { SaveAllScreen.OnScreenShotAllCommand(); if (worker.CancellationPending) { e.Cancel = true; return; } } private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { MessageBox.Show("Search cancelled."); } else if (e.Error != null) { // An error was thrown by the DoWork event handler. MessageBox.Show(e.Error.Message, "An Error Occurred"); } }