Reputation: 147
I am writing a wpf application which pulls data from excel sheet on clicking a button and loads another window where a datagrid is present which displays the result.
Now it takes 10-12 seconds to load the second window and during this time my application freezes. Now what I want is to display a little circular ribbon shaped button which will revolve and a "Please wait" text is displayed. This will be displayed in the centre of the first window and the other contents of the first window will become dimmer.
After the second windows is loaded , the first window closes. Please tell me how to do this.
Upvotes: 1
Views: 240
Reputation: 147
The problem is resolved. Thanks a lot for your help. Following is the code I used.
namespace ScoreX
{
public partial class Score : Window
{
Applications ap;
public Score()
{
InitializeComponent();
}
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
//cb is Circular progress bar
cbProgress.Visibility = Visibility.Hidden;
//Some codes
}
private void btnProceed_Click(object sender, RoutedEventArgs e)
{
//Some lines of Codes
Thread t1 = new Thread(new ThreadStart(CalculateData));
t1.SetApartmentState(ApartmentState.STA);
t1.Start();
cbProgress.Visibility = Visibility.Visible;
}
private void CalculateData()
{
//Some codes
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate()
{
ap = new Applications();
this.Close();
ap.ShowDialog();
}
);
}
Upvotes: 1