I have a System.Timers.Timer object that I want to use, but I don’t want the processing tied to the Timer to interfere with normal to high priority threads. In other words, I’d like to say that I want to process X every 5 seconds as long as nothing else is running.
How could I ensure that my Timer operations are running in a low-priority manner?
The nice thing about System.Timers.Timer is that you can assign a synchronzing object via the
SynchronizingObjectproperty and then exploit it to run theElapsedevent a thread whose priority can be controlled.Just assign an instance of the
ElapsedEventReceiverto theSynchronizingObjectproperty of your timer.Disclaimer: I whipped this up pretty fast so you will need to add your own finishing touches to make it more robust.