
Signature
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
What You Seek Is What You Get.
Why waste the overhead time of initializing a Thread and tearing it down
after every execution? More time and resources would be wasted getting
everything configured and up and running for the Thread each time. So back
to my original question?
> Why not use a timer and run the threads when you need to, rather than
> putting them to sleep? That way, all you have to do is stop the timer.
[quoted text clipped - 13 lines]
>> service actually dies on it's own for some reaon (i.e. god forbid
>> locking)?
William Stacey [MVP] - 14 Jul 2006 01:59 GMT
Running is pooling loop is not right either. A ~better way is to have
thread block on an empty work queue. A clean way to stop is to enqueue
multiple "Close" objects to the queue, so each thread will see a
Close/Shutdown object and exit nicely. Another way is to flip your flag (in
a sync context - lock) then Interrupt each thread. Each thread will get the
Interrupt exception which they will catch and drop out of their loops
respectively. Don't use Abort.

Signature
William Stacey [MVP]
| Why waste the overhead time of initializing a Thread and tearing it down
| after every execution? More time and resources would be wasted getting
[quoted text clipped - 18 lines]
| >> service actually dies on it's own for some reaon (i.e. god forbid
| >> locking)?
William Stacey [MVP] - 14 Jul 2006 02:04 GMT
should be "Running in a pooling loop is not right either".

Signature
William Stacey [MVP]
| Running is pooling loop is not right either. A ~better way is to have
...
Kevin Spencer - 14 Jul 2006 11:24 GMT
You have a point. Actually, thinking back on my own solution, what I did was
to put the timer into the thread. The thread creates an instance of a class
with a timer in it, which fires and triggers an action. The class in the
thread can then be signalled to stop the timer.

Signature
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
What You Seek Is What You Get.
> Why waste the overhead time of initializing a Thread and tearing it down
> after every execution? More time and resources would be wasted getting
[quoted text clipped - 18 lines]
>>> if the service actually dies on it's own for some reaon (i.e. god forbid
>>> locking)?