What I want to achieve is quite simple, and it can be accomplished by a always-running console program like below:
class Program
{
static void Main(string[] args)
{
while (true) {
DateTime now = DateTime.Now;
if(now==timeToRunTask)
runMyTask();//e.g. send an email to Joe
}
}
}
I wonder if this approach is very inefficient in terms of what I'm trying to achieve. And I saw some information about using Task Scheduler so I wonder if I should use that. I'm using Windows Server. But I'd like to know why I shouldn't use the above approach first. Thanks!
Aucun commentaire:
Enregistrer un commentaire