I want to run my schedule task after 3 second, for that i have written code in my WPF application.
using (var ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.Settings.MultipleInstances = TaskInstancesPolicy.IgnoreNew;
td.RegistrationInfo.Description = "TestAPP";
var trigger = new TimeTrigger();
trigger.Repetition.Interval = TimeSpan.FromSeconds(3000);
lblProcess.Content = DateTime.Now.Second; //print current second in a label.
td.Triggers.Add(trigger);
td.Actions.Add(new ExecAction(System.Reflection.Assembly.GetExecutingAssembly().Location, null, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)));
ts.RootFolder.RegisterTaskDefinition(@"TestTask", td);
}
Here i want to check that after ruining from VS, it will run every 3 second or not, so I've print current second to the label lblProcess
.
But it does not updated on every 3 second, Am I doing anything wrong?
EDIT-1:
I've read this before : Creating Scheduled Tasks
There is nothing like to how to check.
Edit-2:
If i use 3.0
instead of 3000
then it's give me an error.
Specified argument was out of the range of valid values.Parameter name: Interval
You cannot set interval in Task Scheduler less than one minute