I have a windows service where in I want to create a file every 10 seconds.
I got many reviews that Timer in Windows service would be the best option.
How can I achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly, pick the right kind of timer. You want either
System.Timers.TimerorSystem.Threading.Timer– don’t use one associated with a UI framework (e.g.System.Windows.Forms.TimerorDispatcherTimer).Timers are generally simple
Elapsedevent (or pass it a callback on construction),and all will be well.
Samples:
I have a bit more information on this page, although I haven’t updated that for a long time.