There are some usages for adding TileTask to ScheduledActionService but I didn't understand which one is best usage. For example;
private void StartPeriodicAgent(string taskName)
{
tilePeriodicTask = ScheduledActionService.Find(taskName) as PeriodicTask;
if (tilePeriodicTask != null)
{
RemoveAgent(taskName);
}
tilePeriodicTask = new PeriodicTask(taskName);
tilePeriodicTask.Description = "App Tile Agent";
try
{
ScheduledActionService.Add(tilePeriodicTask);
// If debugging is enabled, use LaunchForTest to launch the agent in one minute.
#if(DEBUG)
ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(30));
#endif
}
catch (InvalidOperationException)
{
//MessageBox.Show(ex.ToString());
}
catch (SchedulerServiceException)
{
}
}
This method is remove existing tileTask and add again everytime. Is it true? Have I remove and add it again every usage? Or Shouldn't I remove-add it if it exists?
Thanks.