title: Scheduling an application action in wpf
body: <p>I am trying to create a WPF media application for running audio files using Media Element.
  I succeeded in it . But i want to schedule playing a songs which i selected in some interval of time repeatedly. Say 10'o clock in every day or in every hour etc..</p>
  
  <p>What is the best way to do that ?</p>
  
  <p>Initially am think about doing it using a Timer.  But that makes my code complex because i have to play multiple songs in different intervals set by user.</p>
  
  <p>Recently i go to know about <a href="http://taskscheduler.codeplex.com/wikipage?title=Examples&amp;referringTitle=Home" rel="nofollow">Task Scheduler</a> and i run their sample code [open a notepad] and it works perfectly.</p>
  
  <pre><code>  using (TaskService ts = new TaskService())
    {
       // Create a new task definition and assign properties
       TaskDefinition td = ts.NewTask();
       td.RegistrationInfo.Description = "Does something";
  
       // Create a trigger that will fire the task at this time every other day
       td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
  
       // Create an action that will launch Notepad whenever the trigger fires
       td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));
  
       // Register the task in the root folder
       ts.RootFolder.RegisterTaskDefinition(@"Test", td);
  
       // Remove the task we just created
       ts.RootFolder.DeleteTask("Test");
    }
  </code></pre>
  
  <p>How do i define an action which play a song on this context ? Currently they are providing ExecAction,SendEmail,ShowMessage and ComHandlerAction <a href="http://taskscheduler.codeplex.com/wikipage?title=ActionSamples&amp;referringTitle=Examples" rel="nofollow">see this link</a></p>
  
  <p>Or Can we invoke play method of my application by this Task Scheduler? Please help me by providing any idea .</p>
  
  <p>Thanks</p>