example wtih multithreading and ping

  • Thread starter Thread starter Heike Pertzel
  • Start date Start date
H

Heike Pertzel

Hallo NG!

I'm looking for an example showing how to use multithreading with for
example ping (I know how to use ping).
I'm sure I have seen one but I can't find it now.

Can anybody help me please???

I would be happy about every hint
Heike Pertzel
 
I'm looking for an example showing how to use multithreading with for
example ping (I know how to use ping).

What kind of example do you want? The simplest version would just be a
method that uses an instance of the Ping class, which you use a the
ThreadStart delegate for a Thread, which you create and call Start() on.

Maybe you could be more clear about what aspect of the multithreading you
want help with.

Pete
 
Hi,

can you give more dtails about what you want?
Is your question regarding how to use multithread apps?
 
Hallo!

yes, I'm looking for examples for multithread apps
I would like to send a lot of pings in a great network and collect the
answers.
Pinging in sequence that would take a lot of time. I would like to
multithread this. I'm sure I've seen an example, but I can't find it now.

Do you know some place to find examples for that?

Thanks in advance!

Heike Pertzel
 
Hallo!

yes, I'm looking for an example as you've mentioned it below.
Do you know some place to find examples for that?

Thanks in advance!

Heike Pertzel
 
yes, I'm looking for examples for multithread apps
I would like to send a lot of pings in a great network and collect the
answers.
Pinging in sequence that would take a lot of time. I would like to
multithread this. I'm sure I've seen an example, but I can't find it now.

Do you know some place to find examples for that?

Not off the top of my head. It would be relatively easy to write one, but
I don't think you really want to do this using threading. The Ping class
has a usable asynchronous API, which I think you should use. You can
subscribe to the PingCompleted event to receive notification of the
completion of pings that you've initiated using the SendAsync() method.

You can only have one uncompleted ping per Ping instance, so you'd want to
create the same number of Ping instances as the number of simultaneous
started-but-uncompleted pings you want. I suspect that doing it this way
will perform better and use less resources than creating a new thread for
each ping, or assigning the ping to a thread pool thread (to name a couple
of threading techniques you might have otherwise used).

Because the Ping class obviously has to use some sort of network resource,
I'm assuming that you'd want to create a fixed number of Ping instances
and reuse them as they complete. But if it turns out I'm wrong about
that, you might even be able to get away with just creating a whole new
Ping instance for each ping attempt.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top