Reputation: 16837
I have make a file upload/download functionality where the front end is a WPF UI.
I have figured out that to make my UI not freeze, I need to do the upload/download in a separate thread.
But I also need to show a progress bar while uploading/downloading. I want to do this by showing a new WPF form with a progress bar, and during the upload/download the original form should be made inactive for the user ( user may not click any button etc. ); user can only see the progress bar moving in the new form; upon completion, the new form needs to close and original form becomes active again.
Can someone please help me.
Thanks.
Upvotes: 1
Views: 634
Reputation: 6679
First of all, to show a modal Window, all you need to do is
myModalWindow.ShowDialog();
If you use the Show() method, it will just show the window. But if you use the ShowDialog() method, all other windows in your WPF app will not respond to user input until that window closes.
Secondly, you can update a progress bar from another thread by using the UI thread's dispatcher.
Application.Current.Dispatcher.BeginInvoke(() => myProgressBar.Value = progress);
Upvotes: 0
Reputation: 25742
You can implement a simple progress bar. Take this as a start: http://www.codeproject.com/KB/WPF/WpfProgressBar.aspx You can update the progress bar via a callback method from the downloader thread to update the progress every second or so.
Upvotes: 0