简体   繁体   中英

Run Windows Service after particular time

I have created windows service. I need to run that automatically after 2 minutes. For that i have called System.Timers.Timer under OnStart and set the interval to 2 minutes (after converting from millseconds) and made than enabled as true

I have also made Timer Stopped and made that enabled as false in OnStop Method.

Is that ok or i'm missing anything? Let me know

thanks for your help!

you need to set Timer.AutoReset=true after InitializedComponent() or in your OnStart function before you set Timer.Enabled = true and do remember you need to define your Timer in Class level

See Timer.AutoReset Property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM