Example #1
0
        private void TestBtn_Click(object sender, EventArgs e)
        {
            try
            {
                AdslDataValidate();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            string     adslName = adslNameBox.Text;
            RASDisplay ras      = new RASDisplay();

            try
            {
                if (!ras.IsConnected)
                {
                    ras.Connect(adslName);
                    return;
                }
                ras.Disconnect();      //断开连接
                //Thread.Sleep(2000);
                ras.Connect(adslName); //重新拨号
                MessageBox.Show("测试成功");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void ChangeIP(int time = 3000)
        {
            try
            {
                //Console.WriteLine("开始更换IP...");
                ////断线
                //var str_res = hwru.Get("http://192.168.31.1/cgi-bin/luci/;stok=6186d3eefba2d6f4b9cc56e0c158e8ba/api/xqnetwork/pppoe_stop", "", Encoding.UTF8);
                //Console.WriteLine(str_res);
                //Thread.Sleep(time);
                //str_res = hwru.Get("http://192.168.31.1/cgi-bin/luci/;stok=6186d3eefba2d6f4b9cc56e0c158e8ba/api/xqnetwork/pppoe_start", "", Encoding.UTF8);

                //Console.WriteLine(str_res);
                //Console.WriteLine("更换IP完毕");
                //Thread.Sleep(time);

                Console.WriteLine("开始更换IP...");
                //断开连接并重新拨号
                //断线
                RASDisplay ras = new RASDisplay();
                ras.Disconnect();
                Thread.Sleep(time);
                ras.Connect("ADSL");
                Console.WriteLine("更换IP完毕");
            }
            catch (Exception err)
            {
                Console.WriteLine("更换IP失败:" + err.Message);
            }
        }
Example #3
0
        //void Thread_OnCollectionTorrentClear(object sender, EventArgs e)
        //{
        //    Console.WriteLine("执行完了,停止了所有线程的执行。");
        //    //threadTwo.Abort();
        //    //threadOne.Abort();

        //}

        private void ChangeIP(int time = 3000)
        {
            try
            {
                Monitor.Enter(this);//锁定,保持同步


                //6186d3eefba2d6f4b9cc56e0c158e8ba

                //Console.WriteLine("开始更换IP...");
                ////断线
                //var str_res = hwru.Get("http://192.168.31.1/cgi-bin/luci/;stok=6186d3eefba2d6f4b9cc56e0c158e8ba/api/xqnetwork/pppoe_stop", "", Encoding.UTF8);
                //Console.WriteLine(str_res);
                //Thread.Sleep(time);
                //str_res = hwru.Get("http://192.168.31.1/cgi-bin/luci/;stok=6186d3eefba2d6f4b9cc56e0c158e8ba/api/xqnetwork/pppoe_start", "", Encoding.UTF8);

                //Console.WriteLine(str_res);
                //Console.WriteLine("更换IP完毕");
                //Thread.Sleep(time);

                //http://192.168.31.1/cgi-bin/luci/;stok=a97bafa48609a54c8bebcf5c894c7833/api/xqnetwork/pppoe_status

                Console.WriteLine("开始更换IP...");
                //断开连接并重新拨号
                //断线
                RASDisplay ras = new RASDisplay();
                ras.Disconnect();
                Thread.Sleep(time);
                ras.Connect("ADSL");
                Console.WriteLine("更换IP完毕");

                Monitor.Exit(this);//取消锁定
            }
            catch (Exception err)
            {
                Console.WriteLine("更换IP失败:" + err.Message);
            }
        }
Example #4
0
 //ADSL操作
 private static void RasOperate(string type)
 {
     if (type.Equals("connect"))
     {
         new Thread(RasConnect).Start();
         bool online = false;
         int  count  = 0;
         do
         {
             online = Net.IsOnline();
             if (!online)
             {
                 Thread.Sleep(500);
                 CloseException();
             }
             count++;
         } while (!online && count < 60);
     }
     else
     {
         ras = new RASDisplay();
         ras.Disconnect();
     }
 }
Example #5
0
 //ras子线程,处理IE8线程阻塞
 private static void RasConnect()
 {
     ras = new RASDisplay();
     ras.Connect(ConfigCore.AdslName);
 }