Esempio n. 1
0
        private void SwitchNetwork(ref int switchtimes, ref int tries)
        {
            if (!NetworkHelper.IsConnected())
            {
                SetMessageLn("你的电脑还没有连接到Internet,请先检查网络连接是否正常。");
            }
            else if (this._proxy != null)
            {
                SetMessageLn("检测到你为开心助手设置了代理服务器,请检查下设置是否正确。");
            }

            //if (NetworkHelper.IsMSNetwork())
            //{
            switchtimes++;
            if (switchtimes >= 4)
            {
                SetMessageLn("已经尝试切换代理服务器3次,放弃。");
                return;
            }
            //if (NetworkHelper.IsMSProxyEnabled())
            if (this._proxy == null)
            {
                SetMessageLn("第" + switchtimes.ToString() + "尝试[使用]设定的代理服务器访问,5秒钟后重发请求...");
                Thread.Sleep(5000);
                this.EnableProxy();
            }
            else
            {
                SetMessageLn("第" + switchtimes.ToString() + "尝试[取消]设定的代理服务器访问,5秒钟后重发请求...");
                Thread.Sleep(5000);
                this._proxy = null;
            }

            tries = 1;
            //}
        }