title: Why WhenAll waits indefinetely with multiple pings?
body: <p>My application needs to ping all possible IP addresses in a network. Since the IP list is big (about 4000 entries) I decided to do the ping asynchronously to speed up the process. The code I wrote initially seemed to work fine, but somehow when I tried it yesterday it didn't work as expected anymore (maybe after some .NET updates? I don't really know).</p>
  <p>Here is how my code works: from the list of IP addresses I created a list of tasks (one for each IP) and then passed the list of tasks to WhenAll to wait for all ping requests to finish. The problem is that sometimes WhenAll waits indefinitely (I checked it with the debugger and I saw that some of the tasks passed to WhenAll always remained in the State &quot;Waiting for activation&quot;). The strange thing is that sometimes (about 2 times in 3 tests) it works as expected and all tasks completes.</p>
  <p>Here is the code I used:</p>
  <pre><code>    public static async Task&lt;List&lt;PingReply&gt;&gt; PingAsync(List&lt;IPAddress&gt; ips, int timeout)
       {
           var pingTasks = ips.Select(ip =&gt;
           {
               using (Ping ping = new Ping())
               {
                   return ping.SendPingAsync(ip, timeout);
               }
           });
      
           var results = await Task.WhenAll(pingTasks);
      
           return results.ToList();
       }
  </code></pre>
  <p>Any hint on what the problem could be?</p>