Smokey Grindle wrote:
every MS person I ever talked to said use threading.timer s... I am talking
about in person here at tech demos and such... they always shyed away from
using while loops and sleeping
IMHO, there's one very Good Reason for /not/ using a Timer.
It's called JIT compilation.
You write a Service and put a Timer in it.
You code up the routine that the Timer calls.
This routine references an external Assembly.
You deploy the Service.
Somehow, you miss the dependent assembly.
Your deployed service runs!
It starts and stops perfectly!
It doesn't report /any/ errors or Exceptions!
But it never does any useful work.
Why???
When the Timer fires, the runtime attempts to JIT the method invoked by
the Timer.
With the referenced Assembly /missing/, this JIT-linking fails but the
runtime doesn't report this and, if the Exception gets logged anywhere,
I've /never/ managed to find it. You can't catch this Exception - it's
gets thrown into the depths of the runtime and the Service
Infrastructure - you never see it.
I've found that calling the "worker" method from another one inside the
service - one /with/ a loop and Sleep(s) - works 100% reliably, and you
even get to catch the Exception if you really want to. ;-)
Regards,
Phill W.