private void Button_Click_1(object sender, RoutedEventArgs e) { MyProgress.ProgressIndicator progressIndicator = new MyProgress.ProgressIndicator(); progressIndicator.Text = "正在加载中"; progressIndicator.Show(); Task.Factory.StartNew(async() => { Task.Delay(3000).Wait(); await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { progressIndicator.Hide(); }); }); }
private void Button_Click_2(object sender, RoutedEventArgs e) { MyProgress.ProgressIndicator progressIndicator = new MyProgress.ProgressIndicator(); progressIndicator.Text = "处理的进度"; progressIndicator.ProgressType = MyProgress.ProgressTypes.DeterminateMiddle; progressIndicator.Show(); Task.Factory.StartNew(async() => { for (int i = 0; i <= 10; i++) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { progressIndicator.ProgressBarValue = i * 10; if (i >= 10) { progressIndicator.Hide(); } }); Task.Delay(1000).Wait(); } }); }