我只想在给定日期执行一次函数,并且我已经完成了Task
. 我应该怎么办?
static void Main(string[] args)
{
DateTime date = GetExecuteTime();
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "run method";
TimeTrigger d = new TimeTrigger();
d.StartBoundary = date;
td.Triggers.Add(d);
//td.Actions.Add();
}
Console.ReadKey(true);
}