每天,每周,每周为Windows服务创建Scheduler [英] creating Scheduler Daily,Hourly,Weekly for windows service

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

问题描述

我有一个Windows窗体应用程序
并安装在两个以上的系统中
在局域网中或在网络中说.


中进行了任何修改时 主模块.更新已发送
使用Windows来访问每个系统
服务在每个系统中在后台运行.

当更新到达特定系统时
notifyIcon通知用户更新
可用,然后开始更新.

更新是根据app.config文件中设置的updateinterval时间安排的,
是xml文件.我们可以手动设置更新间隔
应该开始.

现在我要在这里
用户界面,以便
用户可以通过设置一天和一周中的特定时间,将服务安排为每日",每小时",每周"和现在"选项.

如我们所见,在Java更新的情况下,有一个系统任务栏图标.右键单击该图标会显示更新/计划选项.

我想要一些功能相同的功能.我想着上下文菜单,但是我应该如何设置时间间隔.

任何示例或想法.
请提供帮助.

I have a windows form application
and is installed in more than two systems
in LAN or say in network.

When Any modification is done in the
Main Module. Updates are sent
to each system using a windows
service which run in background in every system.

When update reaches to particular system
a notifyIcon notifies the user that updates
are available ,and then updating starts.

Updation is scheduled as per the updateinterval time set in the app.config file which
is a xml file .There we can Set manually the interval after which the updation
should start.

Now I want here that
a user Interface so that
user can schedule the service as Daily ,Hourly,weekly and Now options by setting a specific time of the day and week.

As we all have seen in case of Java updates .There is a system tray Icon.On right clicking the Icon it shows the Updation/scheduling options.

I want the some how the same Functionality .Am thinking of Context menu ,but how should i set the Time Interval.

Any Examples or Idea.
Please assist.

推荐答案

当然,您可以在服务中使用计时器并计算适当的时间以启动计划的操作.应基于当前时间(System.DateTimeNow)计算时序.但是,您也可以使用Windows中已经可用的外部服务.

它已经与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 use the timer inside your service and calculate appropriate times to launch your scheduled actions. The timing should be calculated based on the current time (System.DateTimeNow). But alternatively you can use external service already available in Windows.

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


这篇关于每天,每周,每周为Windows服务创建Scheduler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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