How to schedule a C# Windows Service to run a method daily? [duplicate]

谁说我不能喝 提交于 2019-12-01 10:58:50

This code should do it:

Trigger tg = new DailyTrigger();
ScheduledTasks st = new ScheduledTasks();
Task t = st.OpenTask("foo");
t.Triggers.Add(tg);
t.Save();

Create a scheduled task. It's by far the easiest way. If you've got enough access to install a service you should have enough access to set up a scheduled task.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!