c# - 如何每天在同一时间执行一次c#服务中的代码? [英] How to execute code in c# service one time per day at the same hour?

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

问题描述

所以这是我的问题,我需要在每天凌晨 3 点通过 ftp 获取文件的服务器上运行一个 c# 服务.我认为我可以使用 thread.sleep() 或通过将 DateTime.Now 与凌晨 3 点进行比较来做到这一点......

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....

你有更好的解决方案吗?

Do you have better solution?

非常感谢您的帮助!

推荐答案

编写控制台应用程序或等效应用程序,并使用 Windows 调度程序(或现在称为的任何名称...)每天运行它.

Write a console app or equivalent, and use the Windows Scheduler (or whatever it's called nowadays...) to run it daily.

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

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