368d6fafea
Code backup
22 lines
500 B
C#
22 lines
500 B
C#
using System.Net.NetworkInformation;
|
|
|
|
using var ping = new Ping();
|
|
var host = "palsgnfrs01.pal.local";
|
|
|
|
while (true)
|
|
{
|
|
try
|
|
{
|
|
var reply = await ping.SendPingAsync(host, 3000);
|
|
|
|
if (reply.Status != IPStatus.Success)
|
|
Console.WriteLine($"{DateTime.Now} | Get status {Enum.GetName(reply.Status)}");
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine($"{e.Message}\r\nAn error occurred while attempting to ping {host}");
|
|
}
|
|
|
|
await Task.Delay(5000);
|
|
} |