scheduled-taskscodeplex

Run Task Immediately Microsoft.Win32.TaskScheduler


I'm using Task Scheduler Managed Wrapper from Codeplex and I need to fire task as soon as possible and only once. I don't found any API that could execute created task immediately (I can be wrong). So how can I create a trigger that fires only once and as soon as possible?


Solution

  • Found solution here.

    using (TaskService ts = new TaskService())
    {
       string task = "TaskName";
       // This will find it even if its down in a folder. Alternately you could call:
       // Task t = ts.GetTask(task);
       Task t = ts.FindTask(task);
       if (t != null)
          t.Run();
    }