I cannot see why not. One of the
System.Net.NetworkInformation.SendAsync
methods will really allow you to save time if you want to ping several IPs at the same time. The only alternative I see would be creating the same number of threads (preferably using the thread pool or
BackgroundWorker
) and pinging synchronously each separate IP in each separate thread.
[EDIT]
Let's get back to
SendAsync
. How to wait for all of the ping requests? Look at this example:
http://msdn.microsoft.com/en-us/library/ms144961.aspx[
^].
It shows how to wait for
AutoResetEvent
(just one), which is a class derived from
System.Threading.WaitHandle
. How to wait for them all? Use the same instance of
AutoResetEvent
for all pings and use
System.Threading.WaitHandle.WaitAll
for wait. Try it.
—SA