窗户服务问题 [英] Problem a Window Services

查看:80
本文介绍了窗户服务问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我想在9:00 AM到9:00 PM运行我的窗口服务,并且在9:00 PM之后,我的所有记录仅保存到另一个表中,只有一个时间和一个月的最后一天,所有记录都将被删除,并且最后一天的记录将被保存. ...请帮助我,我的窗口服务将在9:00 AM到9:00 PM运行...

Hi...
I want to run my window service at 9:00AM to 9:00PM and after the 9:00PM my all records save to another Table only one time and last day of month all records will be deleted and last day record will be save..... please help me my window service is running at 9:00AM to 9:00PM......

推荐答案

当然,您可以添加任何类型的仅仅因为可以使用计时器和System.DateTime结构就可以为服务计时,请参见:
http://msdn.microsoft.com/en-us/library/system.timers. timer.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.threading. timer.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.datetime.aspx [ ^ ].

但是,我想提出不同的建议.您不认为最好使用旨在支持真正复杂的计划的现有服务吗?它已经与Windows捆绑在一起并启用了;您可以在不同级别上使用它.它称为窗口任务计划程序",请参见 http://en.wikipedia.org/wiki/Windows_Task_Scheduler [ ^ ].

首先,您可以使用命令行实用程序AT.EXE或CSHTASKS.EXE(将替换AT.EXE)来安排事件,请参见:
http://en.wikipedia.org/wiki/At_%28Windows%29 [ ^ ],
http://en.wikipedia.org/wiki/Schtasks [ http://technet.microsoft.com/en-us/library/bb490866.aspx [ ^ ],
http://msdn.microsoft.com/zh-我们/library/windows/desktop/bb736357%28v=vs.85%29.aspx [ http://msdn.microsoft.com/zh-我们/library/windows/desktop/aa383614%28v=vs.85%29.aspx [ http://msdn.microsoft.com/zh-我们/library/windows/desktop/aa383608%28v=vs.85%29.aspx [ .NET的新任务计划程序类库 [ ^ ].

—SA
Of course you can add any kind of timing to your service just because you can use a timer and System.DateTime structure, see:
http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx[^],
http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

However, I want to give a different advice. Don''t you think you would better off using existing service which is designed to support really complex schedules? It is already bundled with Windows and enabled; you can use it on different levels. It is called Window Task Scheduler, see http://en.wikipedia.org/wiki/Windows_Task_Scheduler[^].

First, you can schedule events using command-line utilities AT.EXE or CSHTASKS.EXE (which is replacing AT.EXE), see:
http://en.wikipedia.org/wiki/At_%28Windows%29[^],
http://en.wikipedia.org/wiki/Schtasks[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[^].

And you also can use Window Task Scheduler API, please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383608%28v=vs.85%29.aspx[^].

To see how can you use it with .NET, see this CodeProject article: A New Task Scheduler Class Library for .NET[^].

—SA


这篇关于窗户服务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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