我如何使用计时器控制在每个星期一执行C#中的程序 [英] How Can i use Timer Control to Execute a program on every monday in c#

查看:147
本文介绍了我如何使用计时器控制在每个星期一执行C#中的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在每个星期一使用计时器控制在c#

How Can i use Timer Control to Execute a program on every monday in c#

推荐答案

中执行程序,基本上,计时器的问题是:您通常不能保证因为每天24小时都将记住定时器设置几天,因为您不能保证某些应用程序始终都在执行.但是要保留计时器,您需要始终运行一些应用程序.此类应用程序的适当形式为 Windows服务.但是您不需要编写自己的Windows服务.

您需要的服务已经存在,称为 Windows Task Scheduler ,请参阅:
http://en.wikipedia.org/wiki/Task_Scheduler [ http://msdn.microsoft.com/en-us/library/aa383614.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/aa384006%28v = VS.85%29.aspx [ ^ ].

有关使用Windows Task Scheduler的信息,请参见上面的最后一个链接.您可以使用 Task Scheduler Managed Wrapper 在程序中使用其API,请参见 http://taskscheduler.codeplex.com/ [^ ].

但是,如果它甚至更简单.
您可以通过Windows实用程序AT.EXE或SchTasks.EXE使用Windows Task Scheduler,请参见:
http://en.wikipedia.org/wiki/At_(Windows) [ http://technet.microsoft.com/en-us/library/bb490866.aspx [ ^ ],
http://en.wikipedia.org/wiki/Schtasks [ http://msdn.microsoft.com/zh-我们/library/windows/desktop/bb736357%28v=vs.85%29.aspx [ http://en.wikipedia.org/wiki/Task_Scheduler [ http://msdn.microsoft.com/en-us/library/aa383614.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/aa384006%28v = VS.85%29.aspx [ ^ ].

有关使用Windows Task Scheduler的信息,请参见上面的最后一个链接.您可以使用 Task Scheduler Managed Wrapper 在程序中使用其API,请参见 http://taskscheduler.codeplex.com/ [^ ].

但是,如果它甚至更简单.
您可以通过Windows实用程序AT.EXE或SchTasks.EXE使用Windows Task Scheduler,请参见:
http://en.wikipedia.org/wiki/At_(Windows) [ http://technet.microsoft.com/en-us/library/bb490866.aspx [ ^ ],
http://en.wikipedia.org/wiki/Schtasks [ http://msdn.microsoft.com/zh-我们/library/windows/desktop/bb736357%28v=vs.85%29.aspx [
Basically, the problem with the just the timer is: you usually cannot guarantee that the timer setting is remembered for days, 24 hours per days, because you cannot guarantee that some application is executed all the time. But to hold a timer, you need some application running all the time. The adequate form of such application would be Windows Service. But you don''t need to write your own Windows Service.

The Service you need already exists, called Windows Task Scheduler, see:
http://en.wikipedia.org/wiki/Task_Scheduler[^],
http://msdn.microsoft.com/en-us/library/aa383614.aspx[^],
http://msdn.microsoft.com/en-us/library/aa384006%28v=VS.85%29.aspx[^].

See the last link above for use of the Windows Task Scheduler. You can use its API in your program using Task Scheduler Managed Wrapper, see http://taskscheduler.codeplex.com/[^].

But if can be even simpler.
You can use Windows Task Scheduler using Windows utilities AT.EXE or SchTasks.EXE, see:
http://en.wikipedia.org/wiki/At_(Windows)[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^],
http://en.wikipedia.org/wiki/Schtasks[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[^].

And you don''t need to write your own Windows Service.

The Service you need already exists, called Windows Task Scheduler, see:
http://en.wikipedia.org/wiki/Task_Scheduler[^],
http://msdn.microsoft.com/en-us/library/aa383614.aspx[^],
http://msdn.microsoft.com/en-us/library/aa384006%28v=VS.85%29.aspx[^].

See the last link above for use of the Windows Task Scheduler. You can use its API in your program using Task Scheduler Managed Wrapper, see http://taskscheduler.codeplex.com/[^].

But if can be even simpler.
You can use Windows Task Scheduler using Windows utilities AT.EXE or SchTasks.EXE, see:
http://en.wikipedia.org/wiki/At_(Windows)[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^],
http://en.wikipedia.org/wiki/Schtasks[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[^].

—SA


请查阅一次

这不是一个精确的解决方案,但可以给您一些想法

http://www. dotnetfunda.com/articles/article931-how-to-send-mail-automatically-for-every-five-minutes-using-csharp.aspx [ ^ ]

.NET计划的计时器 [
Refer these once

It is not a exact solution but give you some idea

http://www.dotnetfunda.com/articles/article931-how-to-send-mail-automatically-for-every-five-minutes-using-csharp.aspx[^]

.NET Scheduled Timer[^]


这篇关于我如何使用计时器控制在每个星期一执行C#中的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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