예제 #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));
        }
예제 #2
0
        public VPN_Stability_Monitor(IPMonitor ipMon)
        {
            SessionInformationStorage sis = new SessionInformationStorage();

            try
            {
                mi        = sis.Deserialize(FILENAME, this);
                ipMonitor = ipMon;
            }
            catch
            {
                mi = new MonitorInformation();
            }
        }