Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my C# Windows app be notified of changes in network status without polling?

Tags:

c#

.net

windows

I would like to be notified when the computer's network connection is established (has a valid IP address) and I would like to do this without polling. Is there a Windows API that can provide these notifications?

like image 277
spig Avatar asked Oct 14 '22 01:10

spig


1 Answers

I would start with the System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged event.

Also WMI events might be possible, fired on changes to the set of Win32_NetworkAdapter or Win32_NetworkConnection instances.

like image 61
Richard Avatar answered Oct 31 '22 17:10

Richard