网络状态检测方式:
1.ping;
缺点:服务端可能拒绝ping命令
2.html get请求;
缺点:延时
3.使用平台底层函数;如windows:InternetGetConnectedState
缺点:待定
...
注:任何网络检测方式都可能发生错误,即当前有网,但检测结果失败。所以,即使网络检测失败,也应该支持用户重新操作。最好的处理方式是软件直接进行业务逻辑,然后在异常发生时处理它们。
参考链接:
https://stackoverflow.com/questions/3802171/how-to-query-internet-connection-status-in-c-sharp