Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Service needs to wait, Thread.Sleep?

I have a c# windows service that needs to execute a database query every 60 seconds (or whatever interval is set in the config file). I'm using Thread.sleep(60) in a while loop to accomplish this. Is there a better way to do this?

Thanks

like image 717
Dan H Avatar asked Apr 06 '10 20:04

Dan H


1 Answers

You can use a System.Threading.Timer to run your code every 60 seconds instead of doing it in a sleeping thread.

like image 177
Reed Copsey Avatar answered Oct 18 '22 14:10

Reed Copsey