Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Have windows service run specific day & time weekly
Hello experts, I'm looking for help here so bear with me. Due to circumstances I have no control over, I cannot use Windows Task Scheduler for this. I have to use a windows service with a System.Timers.Timer call. What I'd like to do is have the service run on a specific day of the week at a specific time that I specify in my app.config file. Here's the code I have so far and I suspect I'm going to need a try/catch block.
protected override void OnStart(string args)
_timer = new System.Timers.Timer();
_timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
_timer.Enabled = true;
_timer.Interval = ReadTime;
protected override void OnStop()
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
_lastRun = DateTime.Now;
_thread = new Thread(new ThreadStart(APFImporter));
_thread.Name = "DoImport";
0 · ·