Exemplo n.º 1
0
        public MainWindow()
        {
            ipMonitor  = new IPMonitor(new WebsiteTester(new HashSet <string>()));
            vpnMonitor = new VPN_Stability_Monitor(ipMonitor);
            InitializeComponent();
            InitializeTextFields();
            Task.Factory.StartNew(() => ipMonitor.Run());
            Task.Factory.StartNew(() => vpnMonitor.Run());

            //Shutdown app when called for (can be replaced with system shutdown)
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    if (vpnMonitor.shutdown)
                    {
                        Application curApp = Application.Current;
                        //curApp.Dispatcher.Invoke(curApp.Shutdown);
                        Thread.Sleep(200);
                        Process.Start("shutdown", "/s /t 0");
                    }
                }
            }
                                  );
            this.Dispatcher.Invoke(() => ipMonitor.AddWebsite(WEBSITE1));
            this.Dispatcher.Invoke(() => ipMonitor.AddWebsite(WEBSITE2));
            this.Dispatcher.Invoke(() => ipMonitor.AddWebsite(WEBSITE3));
        }
Exemplo n.º 2
0
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (!Website_Field.Text.Equals(""))
     {
         this.Dispatcher.Invoke(() => ipMonitor.AddWebsite(Website_Field.Text));
     }
 }