如果您注销,计划任务可能无法执行。我不确定这是否可以被覆盖,但我被未执行的任务所困扰,因为 Windows 会自动更新、重新启动并等待我登录。
另一个考虑因素是,凌晨 3 点通常是许多用户注销的时间。
I've used Scheduled Tasks successfully for backups, but I have a word of caution ...
Scheduled tasks may not be performed if you log out. I'm not sure if this can be overridden, but I have been caught out by tasks not performed because Windows automatically updates, reboots and sits waiting for me to log-in.
Another consideration is that 3AM is a time when many users would normally be logged out.
This is a bad solution, even if you sleep for some time between each check, as it wastes system resources unnecessarily (not only in repeatedly checking the time, but also in the memory usage of the program).
为什么不将其设置为计划任务运行?让它执行然后退出。将 Windows 设置为每天凌晨 3:00 作为计划任务启动该进程。
Why not set this up to run as a scheduled task? Have it execute and then exit. Set up Windows to start the process as a scheduled task at 3:00 AM daily.
发布评论
评论(6)
编写一个控制台应用程序或同等应用程序,并使用 Windows 任务计划程序每天运行它。
Write a console app or equivalent, and use the Windows Task Scheduler to run it daily.
我已成功使用计划任务进行备份,但我有一个警告...
如果您注销,计划任务可能无法执行。我不确定这是否可以被覆盖,但我被未执行的任务所困扰,因为 Windows 会自动更新、重新启动并等待我登录。
另一个考虑因素是,凌晨 3 点通常是许多用户注销的时间。
I've used Scheduled Tasks successfully for backups, but I have a word of caution ...
Scheduled tasks may not be performed if you log out. I'm not sure if this can be overridden, but I have been caught out by tasks not performed because Windows automatically updates, reboots and sits waiting for me to log-in.
Another consideration is that 3AM is a time when many users would normally be logged out.
如果您每天晚上都期待一个文件,那么不必担心它何时到达,只需在文件到达时触发一个事件即可。
查看:
System.IO.FileSystemWatcher
MSDN 上的文件系统观察器
If you are expecting a file every night, instead of worrying about when it arrives, just get an event fired when it does.
Look at:
System.IO.FileSystemWatcher
File System Watcher on MSDN
这是一个糟糕的解决方案,即使您在每次检查之间睡眠一段时间,因为它不必要地浪费系统资源(不仅在重复检查时间,而且在程序的内存使用方面)。
This is a bad solution, even if you sleep for some time between each check, as it wastes system resources unnecessarily (not only in repeatedly checking the time, but also in the memory usage of the program).
System.Threading.Timer
可能适合您。记录在此处
System.Threading.Timer
might work out for you.Documented here
为什么不将其设置为计划任务运行?让它执行然后退出。将 Windows 设置为每天凌晨 3:00 作为计划任务启动该进程。
Why not set this up to run as a scheduled task? Have it execute and then exit. Set up Windows to start the process as a scheduled task at 3:00 AM daily.