本文介绍了如何在C#中的服务在同一时刻执行代码每天一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,这里是我的问题,我需要做的是谁在凌晨3点获取文件上的ftp每天一次的服务器上运行一个C#的服务。我认为我可以用了Thread.Sleep(做)或通过与凌晨3点比较DateTime.Now ....

So here's my problem, I need to do a c# service running on a server who's getting file on ftp one time per day at 3am. I think that I can do it with a thread.sleep() or by compare the DateTime.Now with 3am....

你有更好的解决办法?

非常感谢你的帮助!

推荐答案

更好的解决方案,让Windows使用的为你做它。

Much better solution, let windows do it for you using Scheduled Tasks.

如果只需要一天一次被执行,那么我会去这一点。即使谷歌做它;)

If it only needs to be executed once a day, then I would go for this. Even Google does it ;)

编辑:

要回答的评论,它是作为的说。这是一个高级选项,它的任务设置,包含了一个名为复选框可以打开:如果登录只能运行,这是错误的开始。

To answer the comment, it is as Fredrik has said. It is an Advanced Option, which you can open as the task is set up, containing a checkbox called: "Run only if logged on", which is false to begin with.

这篇关于如何在C#中的服务在同一时刻执行代码每天一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 04:13