开发者

Best way to handle Timers?

开发者 https://www.devze.com 2023-02-18 04:40 出处:网络
I wanted to create something similar to the way anti-virus programs sit in the Tray and can re-do an event (e.g. a scan) on an interval. I have a program that exports data from our SQL server and the

I wanted to create something similar to the way anti-virus programs sit in the Tray and can re-do an event (e.g. a scan) on an interval. I have a program that exports data from our SQL server and the user sets up a queue of what they wanted exported.

I was thinking about using System.Windows.NotifyIcon http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx

and System.Timer http://msdn.microsoft开发者_JS百科.com/en-us/library/system.timers.timer%28v=vs.71%29.aspx

Let's say the user has it set to repeat every X hours or "Every Day" or "Every Wednesday at 5:00". Should I just create a tray icon and

this.Hide();

and setup a timer that ticks and compares the time when the timer was started against whatever criteria the user set? Or, is this an inefficient and memory wasting way to do it? Is there any way to "schedule" an event to fire at a certain time and handle it that way?


You can use Windows scheduled tasks.

There is a library called Task Scheduler Managed Wrapper that can be used to set up tasks from c#.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号