Esempio n. 1
0
 ///<summary>
 /// 得到控制面板中宽带连接对象
 ///</summary>
 public void DoAdslReconnect()
 {
     try {
         if (disconnect != null && connection != null)
         {
             disconnect.DoIt();
             Thread.Sleep(3000);
             connection.DoIt();
             AdslReconnect.DoAdsl(adslUserName, adslPasswd);
             Ping pingSender = new Ping();
             while (true)
             {
                 try {
                     PingReply reply = pingSender.Send("www.baidu.com", 100);
                     if (reply.Status == IPStatus.Success)
                     {
                         Thread.Sleep(500);
                         break;
                     }
                 } catch {
                 }
             }
         }
     } catch {
     }
 }
Esempio n. 2
0
        ///<summary>
        /// 程序开始前获取连接对象
        ///</summary>
        public void Start()
        {
            try {
                SetNetworkAdapter(adslName);//获取“连接”或“断开”对象
                if (disconnect != null)
                {
                    disconnect.DoIt();
                    Thread.Sleep(2000);
                    SetNetworkAdapter(adslName);//获取“连接”对象
                    while (true)
                    {
                        if (connection != null)
                        {
                            break;
                        }
                        SetNetworkAdapter(adslName);
                        Thread.Sleep(500);
                    }
                    connection.DoIt();
                    AdslReconnect.DoAdsl(adslUserName, adslPasswd);
                }
                else
                {
                    connection.DoIt();
                    AdslReconnect.DoAdsl(adslUserName, adslPasswd);
                    SetNetworkAdapter(adslName);//获取“断开”对象
                }
            } catch {
            }
            Ping pingSender = new Ping();

            while (true)
            {
                try {
                    PingReply reply = pingSender.Send("www.google.com", 100);
                    if (reply.Status == IPStatus.Success)
                    {
                        Thread.Sleep(500);
                        break;
                    }
                } catch {
                }
            }
        }