Background:
I have a method that does some processing that I would like to be called over and over again. The method can take between 50 - 200 ms to complete.
Currently I have a System.Timers.Timer that calls the method when it elapses every 250 ms. I feel I I can make this more efficient by having the method "trigger" itself once it has completed.
Notes:
I would like avoid simply using a while loop that calls the method. It should call itself asynchronously perhaps using an event?
Question:
How can I have the method "trigger" itself once it has completed?
You could perform your while loop in a separate thread of execution, as long as you take the necessary multi-threading precautions with things such as locks, condition variables, wait handles, and the like.
If you're working with a WinForms application, you may want to look into using a BackgroundWorker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With