| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace ivf_tl_ControlMain
- {
- /// <summary>
- /// StopWindow.xaml 的交互逻辑
- /// </summary>
- public partial class StopWindow : Window
- {
- public StopWindow(Window w,int val)
- {
- InitializeComponent();
- MyProperty = val;
- Task.Run(() =>
- {
- bool stop = false;
- try
- {
- while (true)
- {
- Dispatcher.Invoke(() =>
- {
- if (MyProperty <= 0)
- {
- Application.Current.Shutdown();
- stop = true;
- }
- MyProperty--;
- //Debug.WriteLine(MyProperty);
- });
- if (stop)
- {
- return;
- }
- Thread.Sleep(999);
- }
- }
- catch (Exception ex)
- {
- string sss = ex.Message;
- }
- });
- }
- public int MyProperty
- {
- get { return (int)GetValue(MyPropertyProperty); }
- set { SetValue(MyPropertyProperty, value); }
- }
- // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty MyPropertyProperty =
- DependencyProperty.Register("MyProperty", typeof(int), typeof(StopWindow), new PropertyMetadata(15));
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- private void Button_Click1(object sender, RoutedEventArgs e)
- {
- Application.Current.Shutdown();
- }
- }
- }
|