I am trying to create a WPF multimedia application to run audio files using Media Element. I have succeeded. But I want to schedule the playback of songs that I have selected over a period of time. Speak 10 hours every day or every hour, etc.
What is the best way to do this?
First, I think about doing this with a timer. But this makes my code complicated because I have to play several songs at different intervals set by the user.
I recently learned about the "Task Scheduler" and I ran my sample code [open notepad] and it works great.
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));
ts.RootFolder.RegisterTaskDefinition(@"Test", td);
ts.RootFolder.DeleteTask("Test");
}
, ? ExecAction, SendEmail, ShowMessage ComHandlerAction .
? , , .