|
@@ -264,7 +264,7 @@ |
264 |
264 |
|
// Bind the list of SyndicationItems to our ListBox. |
265 |
265 |
|
feedListBoxNews1.ItemsSource = listArticoli1; |
266 |
266 |
|
//updateTile(); |
267 |
|
- |
StartPeriodicAgent(); |
|
267 |
+ |
//StartPeriodicAgent(); |
268 |
268 |
|
}); |
269 |
269 |
|
} |
270 |
270 |
|
|
|
@@ -1668,54 +1668,54 @@ |
1668 |
1668 |
|
// } |
1669 |
1669 |
|
//} |
1670 |
1670 |
|
|
1671 |
|
- |
private void StartPeriodicAgent() |
1672 |
|
- |
{ |
1673 |
|
- |
// is old task running, remove it |
1674 |
|
- |
periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask; |
1675 |
|
- |
if (periodicTask != null) |
1676 |
|
- |
{ |
1677 |
|
- |
try |
1678 |
|
- |
{ |
1679 |
|
- |
ScheduledActionService.Remove(periodicTaskName); |
1680 |
|
- |
} |
1681 |
|
- |
catch (Exception) |
1682 |
|
- |
{ |
1683 |
|
- |
} |
1684 |
|
- |
} |
1685 |
|
- |
// create a new task |
1686 |
|
- |
periodicTask = new PeriodicTask(periodicTaskName); |
1687 |
|
- |
// load description from localized strings |
1688 |
|
- |
periodicTask.Description = "This is LiveTile application update agent."; |
1689 |
|
- |
// set expiration days |
1690 |
|
- |
periodicTask.ExpirationTime = DateTime.Now.AddDays(14); |
1691 |
|
- |
try |
1692 |
|
- |
{ |
1693 |
|
- |
// add thas to scheduled action service |
1694 |
|
- |
ScheduledActionService.Add(periodicTask); |
1695 |
|
- |
// debug, so run in every 30 secs |
1696 |
|
- |
#if(DEBUG_AGENT) |
1697 |
|
- |
ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(5)); |
1698 |
|
- |
System.Diagnostics.Debug.WriteLine("Periodic task is started: " + periodicTaskName); |
1699 |
|
- |
#endif |
1700 |
|
- |
|
1701 |
|
- |
} |
1702 |
|
- |
catch (InvalidOperationException exception) |
1703 |
|
- |
{ |
1704 |
|
- |
if (exception.Message.Contains("BNS Error: The action is disabled")) |
1705 |
|
- |
{ |
1706 |
|
- |
// load error text from localized strings |
1707 |
|
- |
MessageBox.Show("Background agents for this application have been disabled by the user."); |
1708 |
|
- |
} |
1709 |
|
- |
if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added.")) |
1710 |
|
- |
{ |
1711 |
|
- |
// No user action required. The system prompts the user when the hard limit of periodic tasks has been reached. |
1712 |
|
- |
} |
1713 |
|
- |
} |
1714 |
|
- |
catch (SchedulerServiceException) |
1715 |
|
- |
{ |
1716 |
|
- |
// No user action required. |
1717 |
|
- |
} |
1718 |
|
- |
} |
|
1671 |
+ |
// private void StartPeriodicAgent() |
|
1672 |
+ |
// { |
|
1673 |
+ |
// // is old task running, remove it |
|
1674 |
+ |
// periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask; |
|
1675 |
+ |
// if (periodicTask != null) |
|
1676 |
+ |
// { |
|
1677 |
+ |
// try |
|
1678 |
+ |
// { |
|
1679 |
+ |
// ScheduledActionService.Remove(periodicTaskName); |
|
1680 |
+ |
// } |
|
1681 |
+ |
// catch (Exception) |
|
1682 |
+ |
// { |
|
1683 |
+ |
// } |
|
1684 |
+ |
// } |
|
1685 |
+ |
// // create a new task |
|
1686 |
+ |
// periodicTask = new PeriodicTask(periodicTaskName); |
|
1687 |
+ |
// // load description from localized strings |
|
1688 |
+ |
// periodicTask.Description = "This is LiveTile application update agent."; |
|
1689 |
+ |
// // set expiration days |
|
1690 |
+ |
// periodicTask.ExpirationTime = DateTime.Now.AddDays(14); |
|
1691 |
+ |
// try |
|
1692 |
+ |
// { |
|
1693 |
+ |
// // add thas to scheduled action service |
|
1694 |
+ |
// ScheduledActionService.Add(periodicTask); |
|
1695 |
+ |
// // debug, so run in every 30 secs |
|
1696 |
+ |
//#if(DEBUG_AGENT) |
|
1697 |
+ |
// ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(10)); |
|
1698 |
+ |
// System.Diagnostics.Debug.WriteLine("Periodic task is started: " + periodicTaskName); |
|
1699 |
+ |
//#endif |
|
1700 |
+ |
|
|
1701 |
+ |
// } |
|
1702 |
+ |
// catch (InvalidOperationException exception) |
|
1703 |
+ |
// { |
|
1704 |
+ |
// if (exception.Message.Contains("BNS Error: The action is disabled")) |
|
1705 |
+ |
// { |
|
1706 |
+ |
// // load error text from localized strings |
|
1707 |
+ |
// MessageBox.Show("Background agents for this application have been disabled by the user."); |
|
1708 |
+ |
// } |
|
1709 |
+ |
// if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added.")) |
|
1710 |
+ |
// { |
|
1711 |
+ |
// // No user action required. The system prompts the user when the hard limit of periodic tasks has been reached. |
|
1712 |
+ |
// } |
|
1713 |
+ |
// } |
|
1714 |
+ |
// catch (SchedulerServiceException) |
|
1715 |
+ |
// { |
|
1716 |
+ |
// // No user action required. |
|
1717 |
+ |
// } |
|
1718 |
+ |
// } |
1719 |
1719 |
|
|
1720 |
1720 |
|
|
1721 |
1721 |
|
|