Skip to content

Instantly share code, notes, and snippets.

@fabriciorissetto
Last active February 2, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabriciorissetto/ca78913af7cadc5abb6550e7aad34bee to your computer and use it in GitHub Desktop.
Save fabriciorissetto/ca78913af7cadc5abb6550e7aad34bee to your computer and use it in GitHub Desktop.
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