Connecting Tech Pros Worldwide Help | Site Map

Monitoring Thread Activity

  #1  
Old November 21st, 2008, 06:55 PM
Jerry Spence1
Guest
 
Posts: n/a
I have a thread which is misbehaving. It's due to a call to
my.computer.network.ping sometimes never responding (I'm assuming this is a
bug in .Net 2.0). 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.

How can I implement the monitoring part?

-Jerry


  #2  
Old November 21st, 2008, 10:05 PM
=?Utf-8?B?QU1lcmNlcg==?=
Guest
 
Posts: n/a

re: Monitoring Thread Activity


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.

  #3  
Old November 21st, 2008, 11:15 PM
Jerry Spence1
Guest
 
Posts: n/a

re: Monitoring Thread Activity



"AMercer" <AMercer@discussions.microsoft.comwrote in message
news:5BC44675-C8CA-47E8-B756-926CE4AE24B0@microsoft.com...
Quote:
Quote:
>I have a thread which is misbehaving. It's due to a call to
>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.
Thanks for your reply. Sometimes the ping statement crashes with a protected
memory exception (I can catch this) and sometimes it never returns (I have a
timeout of 1000ms) which I can't catch. I have tried investigating this
error for ages (it happens on all our production PCs) and felt that some
sort of monitor would be best to crash the thread until I can upgrade to
..Net 3.5.

Yes I thought of a watchdog system but how do I get a handle on the actual
thread (process ID perhaps) and how do I stop it with another process?

-Jerry


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while connecting to DB2 Z/OS from DataStage shsandeep answers 4 July 5th, 2006 06:15 PM
Keep-alived RPC in Python Dody Suria Wijaya answers 0 December 13th, 2005 10:35 PM
Too much CPU usage Froggy / Froggy Corp. answers 1 November 22nd, 2005 08:59 AM
Monitoring Service Activity JSheble answers 3 November 17th, 2005 04:04 AM