I have a thread which is misbehaving. It's due to a call to
Quote:
|
my.computer.network.ping sometimes never responding
|
In what way misbehaving? Ping can raise an exception. Are you handling
exceptions? Ping with a long timeout can wait for a long time before
returning. Do you use the timeout parameter?
Quote:
(I'm assuming this is a
bug in .Net 2.0).
|
I would be surprised if there is a .net bug in this area.
Quote:
I need to have a thread running which constantly monitors
all the other threads in my program (actually implemented using background
workers) and if it stops using CPU, then kill it, and relaunch it.
|
I suggest you investigate why your thread is misbehaving and that you not
implement a thread that watches other threads. But if you must, I would
suggest that each monitored thread periodically append some data to a
thread-safe queue. The data could be anything you want, eg a heartbeat
notification, or some statistics about the thread's throughput, or even some
problem that is the worker thread has encountered. A new thread (or your
main thread) could read this queue from time to time looking for trouble.
But, I urge you to not proceed down this path.