我需要一个事件来检测网络连接/断开 [英] I need a event to detect Internet connect/disconnect

查看:508
本文介绍了我需要一个事件来检测网络连接/断开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发的.NET应用程序,其中的要求之一是监测系统是否被连接到互联网或没有。

We are developing a .NET application where one of the requirements is to monitor whether the system is connected to the internet or not.

我们能够获得一个.NET事件以太网电缆断开,但如果调制解调器复位则此事件不会被触发。我不想继续ping得到这个工作的一些网址,因为它会增加相当大的性能开销。是否有任何.NET事件,可以检查系统是否已连接到互联网或不?

We were able to get a .NET event for "ethernet cable disconnect", but if the modem is reset then this event does not get triggered. I don't want to keep pinging some URL to get this done since it will add considerable performance overhead. Is there any .NET event which can check whether the system is connected to the internet or not?

有其示出了十字标志或当系统不conncected到互联网有限连接登入系统托盘的图标。这表明视窗知道,我想捕获该事件。

There is an icon in system tray which shows a cross sign or limited connectivity sign when the system is not conncected to the internet. That suggests Windows knows, and I want to trap that event.

推荐答案

这是全部覆盖(包括是在网络上,并具有网络之间的区别您连接到Internet)在的 http://msdn.microsoft.com/en-us/library/ee264321(VS.85)。 ASPX 。我希望你的意思是把你的帖子,Windows 7的标签,因为这一切都是pretty的新。

This is all covered (including the difference between being on the network and having the network connect you to the Internet) at http://msdn.microsoft.com/en-us/library/ee264321(VS.85).aspx. I hope you meant to put that Windows 7 tag on your post, because all this is pretty new.

关键是 INetworkListManager.get_IsConnectedToInternet()其pretty的多少做什么它在锡说。你必须跳了一下周围,以注册事件等。 $ C $信用证包装包装一些是为您和具有网络样本,你能适应。

The key is INetworkListManager.get_IsConnectedToInternet() which pretty much does what it says on the tin. You have to jump around a bit to register for the events etc. The Code Pack wraps some of that up for you and has a network sample you can adapt.

这篇关于我需要一个事件来检测网络连接/断开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆