private async void ButtonBase_OnClick_3(object sender, RoutedEventArgs e) { var win = new IndeterminateProgressWindow("Please wait while we are installing the virus into your computer. . ."); win.Show(); //Do Some Staff await Task.Delay(5000); //Change the message the 2nd time win.Message = "Done!!!"; win.Close(); }
/// <summary> /// 显示等待消息 /// </summary> /// <param name="Work">等待时后台任务</param> /// <param name="WaitMessage">等待消息</param> /// <param name="EndMessage">结束消息</param> /// <param name="ParentWindow">父窗体</param> public static void ShowProgressMessage(DoWork Work, string WaitMessage, Window ParentWindow) { IndeterminateProgressWindow win = new IndeterminateProgressWindow(WaitMessage) { Owner = ParentWindow }; Task.Run(() => { Work(ParentWindow, win); ParentWindow.Dispatcher.BeginInvoke(new Action(() => { win.Close(); })); }); win.ShowDialog(); }