【发布时间】:2015-06-29 19:08:12
【问题描述】:
我有点困惑,正在寻求建议。
我想做什么的想法:
Program started
foreach file in directory 'tasks'
Deserialize file to object
DateTime date = GetExcecutionDate()
if (Date.Now.DateDiff(date) < 0)
async object.Excecute()
else
//Set task for file to execute at date
End foreach
Programs continue executing
When Task is called, I need to know filename
async
Deserialize file to object
object.Execute();
ReloadTask(filename); //Sets new fire time for this file
实现此机制的最佳方式是什么。我所需要的只是如何强制程序调用将在特定时间接收字符串的特定方法。我应该以哪种方式挖掘 - Timers 或 Taskers 或其他东西?
【问题讨论】:
-
只需创建一个包含
date和filename的类,然后创建一个List<ClassName>来保存这些实例。现在使用标准 Timer 控件并将其 Interval 设置为您想要检查日期/时间是否已通过的频率(每分钟一次?)。在 Timer 的 Tick 事件中,遍历列表并查看是否应处理任何项目...
标签: c# scheduled-tasks