如何断开与Internet的连接,并在Windows 8中的C#中间隔后重新连接 [英] how to disconnect from internet and connect back after an interval in C# in Windows 8
问题描述
我有一个方案来编写单元测试用例,用于断开互联网并连接回来
假设用户已连接且数据已加载
网络/互联网连接丢失(可以使用C#自动完成此流程,以避免人工干预,如手动拔出n / w电缆并方便自动测试???)
等待10秒
网络/互联网连接返回
继续登录
操作系统:Windows 8
我知道我们可以使用此代码检测PC中的网络连接,但是如果连接存在则如何断开与互联网的连接,然后使用c#
系统连接回来。$ B $ System.Net.NetworkInformation .NetworkInterface.GetIsNetworkAvailable()
I have a scenario to write unit test case for internet disconnection and connecting back
Say user is connected and data is loaded
Network/internet connection is lost(can this flow be automated using C# , to avoid manual intervention like manually unplugging n/w cable and facilitate automate testing ???)
Wait for 10seconds
Network/ internet connection is back
Continue with login
OS : Windows 8
I know we can detect network connection in a PC using this code , but how to disconnect from internet if the connection exists and then get connected back using c#
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
推荐答案
你可以试试WMI
http://msdn.microsoft.com/en-us/library/Aa394595 [ ^ ]
You can try WMI
http://msdn.microsoft.com/en-us/library/Aa394595[^]
这篇关于如何断开与Internet的连接,并在Windows 8中的C#中间隔后重新连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!