Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Program
{
    static void Main()
    {
        const int DoisSegundos = 2000;

        var tasks = new List<Task>();
        var listaEventos = Enumerable.Range(1, 1000);

        listaEventos.ToList().ForEach((idEvento) =>
        {
            tasks.Add(Task.Run(() =>
            {
                Console.Write(".");
                Thread.Sleep(DoisSegundos); //Chamada para um Web Service
            }));
        });

        Task.WaitAll(tasks.ToArray());
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment