日期:2014-05-18 浏览次数:21277 次
Thread op = new Thread(new ThreadStart(YourPing)); op.IsBackground = true; op.Start();
------解决方案--------------------
第一种方法:
//导入dll
[DllImport("wininet.dll", EntryPoint = "InternetGetConnectedState")]
//判断网络状况的方法,返回值true为连接,false为未连接
public extern static bool InternetGetConnectedState(out int conState, int reder);
 //在你的button事件中写下如下代码就行
    private void btnNetStatus_Click(object sender, EventArgs e)
        {
            int n =0;
            if (InternetGetConnectedState(out n,0))
               {
                     MessageBox.Show("网终处于连接状态");
                }
            else
               {
                MessageBox.Show("网络处于未连接状态");
               }
        }