定时扔法每周一次 - C#,Asp.NET [英] Timer to throw Method Once a Week - C#, Asp.NET

查看:375
本文介绍了定时扔法每周一次 - C#,Asp.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一般是相当新的C#和编码。我在一定的时间去寻找一个例子/开源定时器将用于抛出一个基本方法功能(例如电子邮件通知),每周一次。之后做一些研究,我发现,使用定时器,而不是一个Windows服务将是明智的,因为这将有一个非常小的工作量。

I'm fairly new to C# and coding in general. I'm looking for an example/open source Timer Function that will be used to throw a basic method (ex. Email Notifications) once a week at a certain time. After doing some research I've found that using a Timer instead of a Windows Service would be wise as it will have a very small workload.

我发现一对夫妇的计时器API上codePLEX和code项目的,但我有由于我的C#最小的知识工作的麻烦通过例子我的路。

I've found a couple timer API's on CodePlex and Code Project but am having trouble working my way through the Examples due to my minimal knowledge of C#.

有谁知道一个简单的计时器,我可以用这是初学者友好,而且还通过了散步的?或者是有这样做使用System.Timers的一个更简单的方法?

Does anyone know of a Simple timer that I could use that is Beginner friendly and that also has a walk through? Or is there a simpler way of doing this using System.Timers?

我的最终目标是有一个计时器,将在上午8:00逢周一火灾的方法。

My end goal is to have a timer that will fire a Method at 8:00AM every Monday.

编辑:我相信我应该是在我最初的帖子更详细。我选择不使用Windows任务计划的原因是因为我调用方法不仅仅是调用Windows任务更加复杂。

I believe I should have been more detailed in my initial Post. The reason I chose not to use the Windows Task Scheduler is because the Method I am invoking is more complex than just invoking Windows Task.

在定时器击中预定的时间将大火查询DB对于需要一定的时间范围内的服务项目的方法。这将然后循环通过项目将它们添加到将被发送到仓库的管理员的电子邮件。

When the timer hits the scheduled time it will fire a Method which queries the DB for Items requiring service within a certain time-frame. This will then loop through the items adding them to an email which will be sent to that Warehouse's Admin.

如果我没有记错,这是不能被通过Windows任务计划程序做了什么?

If I'm not mistaken, that cannot be done through Windows Task Scheduler?

推荐答案

使用定时器这是没有意义的。你的目标是在特定的时间,以具有功能火灾。如果你的服务器上重新启动?是您的计时器会计算重启时间和周一的确切时间上午8:00?

Using a timer for this makes no sense. Your goal is to have a function fire at a specific time. What if your server reboots? Is your timer going to calculate the exact time between the reboot time and Monday at 8:00 am?

海事组织,使用一个控制台应用程序和Windows任务调度。

IMO, use a console application and the Windows Task Scheduler.

响应修改:当然,你可以使用Windows任务计划程序这一点。调度程序的唯一功能是执行任务。没有规则至于它执行任务的复杂性。此外,查询一个DB和发送电子邮件是不完全一个过于复杂的任务。 :)

Response to edit: Of course you can use Windows Task Scheduler for this. The only function of the scheduler is to execute a task. There are no rules as to the complexity of the task it executes. Plus, querying a DB and sending an email isn't exactly an overly complex task. :)

这篇关于定时扔法每周一次 - C#,Asp.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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