Looking for c# Answers? Try Ask4KnowledgeBase
Looking for c# Keywords? Try Ask4Keywords

C# Language Parallel.For


An example that uses Parallel.For loop to ping a given array of website urls.

static void Main()
    string [] urls = 

    System.Threading.Tasks.Parallel.For(0, urls.Length, i =>
        var ping = new System.Net.NetworkInformation.Ping();

        var result = ping.Send(urls[i]);

        if (result.Status == System.Net.NetworkInformation.IPStatus.Success)
            Console.WriteLine(string.Format("{0} is online", urls[i]));