List<string> sites = new List<string>
{
"www.yahoo.com",
"www.google.com",
"www.aspsnippets.com"
};
List<PingReply> pingReplies = new List<PingReply>();
System.Threading.Tasks.Parallel.ForEach(sites, site =>
{
Ping p = new Ping();
lock (pingReplies)
{
pingReplies.Add(p.Send(site));
}
});
foreach (var s in pingReplies.ToList())
{
Response.Write(s.Address + ": " + s.RoundtripTime + ": " + s.Status + "<br />");
}