Exemple #1
0
        public static void SpeedTester()
        {
            print.Invoke("SpeedTest thread running!");

            var sw        = new Stopwatch();
            int speedFreq = 0;

            try
            {
                speedFreq = Convert.ToInt32(ConfigurationManager.AppSettings["speedFreq"]);
            }
            catch
            {
                print.Invoke("Invalid SpeedTest frequency, stopping SpeedTest thread!");
                terminateSpeed.Invoke();
            }

            while (true)
            {
                sw.Reset();
                sw.Start();

                var it = Tests.DownloadSpeedTest();
                ConsoleOutput.ConsolePrinter.PrintShortSpeedTestResult(it);
                Logging.Instance.LogSpeedTest(it);

                sw.Stop();

                if (sw.ElapsedMilliseconds < speedFreq)
                {
                    Thread.Sleep(speedFreq - (int)sw.ElapsedMilliseconds);
                }
            }
        }
Exemple #2
0
        public static void Pinger()
        {
            print.Invoke("Ping thread started!");
            var targets  = ConfigurationManager.AppSettings["pingTargets"].Split('|');
            int pingFreq = 0;

            try
            {
                pingFreq = Convert.ToInt32(ConfigurationManager.AppSettings["pingFreq"]);
            }
            catch
            {
                print.Invoke("Invalid ping frequency, stopping ping thread!");
                terminatePing.Invoke();
            }

            var sw = new Stopwatch();

            while (true)
            {
                sw.Reset();
                sw.Start();

                foreach (var t in targets)
                {
                    var it = Tests.PingAgregatedTest(t, 200);
                    ConsoleOutput.ConsolePrinter.PrintShortAgregatedPingTestResult(it);
                    Logging.Instance.LogAgregatedPing(it);
                }

                sw.Stop();

                if (sw.ElapsedMilliseconds < pingFreq)
                {
                    Thread.Sleep(pingFreq - (int)sw.ElapsedMilliseconds);
                }
            }
        }