Пример #1
0
        public void runCore()
        {
            Toast.showNotification("开始运行");

            int            unstableTime   = 0;
            Pinger         pinger         = new Pinger();
            WifiController wifiController = new WifiController();

            while (true)
            {
                if (pinger.isConnectionUnstable())
                {
                    try
                    {
                        if (unstableTime == 0 || unstableTime == 2)
                        {
                            Toast.sayReconnect();
                            wifiController.reconnect();
                        }
                        if (unstableTime > 3)
                        {
                            Toast.sayCheck();
                            wifiController.reconnect();
                            Thread.Sleep(10000);
                        }
                    }
                    finally
                    {
                        unstableTime++;
                        Thread.Sleep(5000);
                    }
                }
                else
                {
                    if (unstableTime == 0)
                    {
                        Thread.Sleep(30000);
                    }
                    else
                    {
                        Toast.sayConnectSuccess();
                        unstableTime = 0;
                        Thread.Sleep(15000);
                    }
                }
            }
        }