Result We get an Address if the network location was found. We also can record the time required to access the site.
static void Main()
// Use Task class to start and wait for a Ping.
Task task = new Task(Test);
static async void Test()
// Create Ping instance.Ping ping = new Ping();
// Send a ping.
PingReply reply = await ping.SendPingAsync("dotnetperls.com");
// Display the result.
Console.WriteLine("ADDRESS:" + reply.Address.ToString());
Console.WriteLine("TIME:" + reply.RoundtripTime);
Some notes. The Ping class is ideal for monitoring whether a network location can be reached. It does not ensure anything beyond this.
Notes, async and await. With the async and await keywords we have a more elegant way of handling async methods. The Main method can continue while Test() is busy.
A short summary. With System.Net.NetworkInformation, we can send pings. Async and await can be used to handle multiple tasks at once.