I have a C# Windows Service that has a Timer that checks every 10 seconds a "flag" in my SQL Table
for any Process Pending To Execute.
So right now I have inside my Windows Service:
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
// flag so the process is only executed one at a time.
if (!_isProcessBusy) {
RunProcess();
}
}
private void RunProcessSync() {
_isProcessBusy = true;
// ... here all the code for doing the internal process ...
// when process is Done then change the flag so a new process can be executed
_isProcessBusy = false;
}
Now I need to let the Windows Service Runs multiple threads of the same process, So if in my SQL Table
I have 3 processed to execute then I will let the service run the 3 at the same time.
I was thinking to use System.Threading.Tasks
library but don't know if this is the right approach or maybe there is something easier.