每天,每周,每周为Windows服务创建Scheduler

编程入门 行业动态 更新时间:2024-10-11 23:17:07
本文介绍了每天,每周,每周为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捆绑在一起并启用了;您可以在不同级别上使用它.它称为窗口任务计划程序",请参见 en.wikipedia/wiki/Windows_Task_Scheduler [ ^ ]. 首先,您可以使用命令行实用程序AT.EXE或CSHTASKS.EXE(将替换AT.EXE)来安排事件,请参见: en.wikipedia/wiki/At_%28Windows%29 [ ^ ], en.wikipedia/wiki/Schtasks [ ^ ], technet.microsoft/en-us/library/bb490866.aspx [ ^ ], msdn.microsoft/zh-我们/library/windows/desktop/bb736357%28v=vs.85%29.aspx [ ^ ]. 您还可以使用Window Task Scheduler API,请参见: msdn.microsoft/zh-我们/library/windows/desktop/aa383614%28v=vs.85%29.aspx [ ^ ], msdn.microsoft/zh-我们/library/windows/desktop/aa383608%28v=vs.85%29.aspx [ ^ ]. 若要查看如何将其与.NET结合使用,请参见此CodeProject文章: .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 en.wikipedia/wiki/Windows_Task_Scheduler[^]. First, you can schedule events using command-line utilities AT.EXE or CSHTASKS.EXE (which is replacing AT.EXE), see: en.wikipedia/wiki/At_%28Windows%29[^], en.wikipedia/wiki/Schtasks[^], technet.microsoft/en-us/library/bb490866.aspx[^], msdn.microsoft/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[^]. And you also can use Window Task Scheduler API, please see: msdn.microsoft/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx[^], msdn.microsoft/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

本文发布于:2023-11-27 22:09:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639789.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   Scheduler

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!