Declare a method to handle NetworkAvailabilityChanged events
using System;
using System.Net.NetworkInformation;
class MainClass
{
private static void NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
if (e.IsAvailable)
{
Console.WriteLine("Network Available");
}
else
{
Console.WriteLine("Network Unavailable");
}
}
static void Main(string[] args)
{
NetworkChange.NetworkAvailabilityChanged += NetworkAvailabilityChanged;
}
}
|
HTML code for linking to this page:
Related in same category :
-
|