在特定的日期和时间,每星期C#运行System.Timers.Timer的事件 [英] Run System.Timers.Timer event on specific day and time each week c#

查看:174
本文介绍了在特定的日期和时间,每星期C#运行System.Timers.Timer的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写使用System.Timers.Timer的跟踪我的时间的窗口服务的过程。我想要做的是做起来很基础上,我的app.config文件变量我的服务将在一个特定的日期和时间启动。

I'm in the process of writing a windows service using System.Timers.Timer to keep track of my interval. What I'd like to do is make it so my service will launch on a specific day and time based on variables in my app.config file.

推荐答案

虽然我认为最好的办法是让这个计划的任务,你可以轻松地创建一个可等待计时器,将在每天同一时间发出信号。 Windows有一个可等待计时器对象,但有它没有任何.NET支持。

Although I think your best bet is to make this a scheduled task, you can easily create a waitable timer that will signal at the same time every day. Windows has a Waitable Timer object, but there's no .NET support for it.

我发表了一篇文章而回:可等待在C#中,定时器中,我展示了如何使用这个对象从C#程序。全部code可在 http://www.mischel.com/pubs/waitabletimer.zip 。你可以自由地使用它,你认为合适的方式。

I published an article a while back: Waitable Timers in C#, in which I show how to use this object from a C# program. Full code is available at http://www.mischel.com/pubs/waitabletimer.zip. You're free to use it any way you see fit.

这篇关于在特定的日期和时间,每星期C#运行System.Timers.Timer的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆