Sunday, May 29, 2011

Notification on Network connectivity changes

Today I came to notice a small interesting portion in our project. Its nothing but an event handler which will execute when we connect or disconnect the network cable.According to the network state change the application had to show a Window to get some details. It’s a simple static event

System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += new System.Net.NetworkInformation.NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
void NetworkChange_NetworkAvailabilityChanged(object sender, System.Net.NetworkInformation.NetworkAvailabilityEventArgs e)
{
//e.IsAvailable Give you the current status
}


Oh  forgot to tell about the project.It’s a .Net 3.5 WPF application which extensively uses WCF for communication.


No comments: