Monitoring Thread Activity

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry Spence1

    Monitoring Thread Activity

    I have a thread which is misbehaving. It's due to a call to
    my.computer.net work.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


  • =?Utf-8?B?QU1lcmNlcg==?=

    #2
    RE: Monitoring Thread Activity

    I have a thread which is misbehaving. It's due to a call to
    my.computer.net work.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?
    (I'm assuming this is a
    bug in .Net 2.0).
    I would be surprised if there is a .net bug in this area.
    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.

    Comment

    • Jerry Spence1

      #3
      Re: Monitoring Thread Activity


      "AMercer" <AMercer@discus sions.microsoft .comwrote in message
      news:5BC44675-C8CA-47E8-B756-926CE4AE24B0@mi crosoft.com...
      >I have a thread which is misbehaving. It's due to a call to
      >my.computer.ne twork.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?
      >
      >(I'm assuming this is a
      >bug in .Net 2.0).
      >
      I would be surprised if there is a .net bug in this area.
      >
      >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


      Comment

      Working...