Nextrek
Diff Revisions
48
vs
49
for /WindowsPhone/NotizieTL/NotizieTL/App.xaml.cs
|
@@ -1,4 +1,6 @@ |
1 |
|
- |
using System; |
|
1 |
+ |
#define DEBUG_AGENT |
|
2 |
+ |
|
|
3 |
+ |
using System; |
2 |
4 |
|
using System.Collections.Generic; |
3 |
5 |
|
using System.Linq; |
4 |
6 |
|
using System.Net; |
|
@@ -13,6 +15,7 @@ |
13 |
15 |
|
using Microsoft.Phone.Controls; |
14 |
16 |
|
using Microsoft.Phone.Shell; |
15 |
17 |
|
using System.IO.IsolatedStorage; |
|
18 |
+ |
using Microsoft.Phone.Scheduler; |
16 |
19 |
|
|
17 |
20 |
|
|
18 |
21 |
|
namespace NotizieTL |
|
@@ -101,7 +104,20 @@ |
101 |
104 |
|
// This code will not execute when the application is closing |
102 |
105 |
|
private void Application_Deactivated(object sender, DeactivatedEventArgs e) |
103 |
106 |
|
{ |
104 |
|
- |
|
|
107 |
+ |
var taskName = "LiveTilePeriodicAgent"; |
|
108 |
+ |
PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; |
|
109 |
+ |
if (periodicTask != null) |
|
110 |
+ |
ScheduledActionService.Remove(taskName); |
|
111 |
+ |
|
|
112 |
+ |
periodicTask = new PeriodicTask(taskName) { Description = "Periodic task to update the tile of <your app>." }; |
|
113 |
+ |
try |
|
114 |
+ |
{ |
|
115 |
+ |
ScheduledActionService.Add(periodicTask); |
|
116 |
+ |
//#if DEBUG_AGENT |
|
117 |
+ |
ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(10)); |
|
118 |
+ |
//#endif |
|
119 |
+ |
} |
|
120 |
+ |
catch (InvalidOperationException) { } |
105 |
121 |
|
} |
106 |
122 |
|
|
107 |
123 |
|
// Code to execute when the application is closing (eg, user hit Back) |
|
@@ -109,7 +125,20 @@ |
109 |
125 |
|
private void Application_Closing(object sender, ClosingEventArgs e) |
110 |
126 |
|
{ |
111 |
127 |
|
// Ensure that required application state is persisted here. |
112 |
|
- |
|
|
128 |
+ |
var taskName = "LiveTilePeriodicAgent"; |
|
129 |
+ |
PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; |
|
130 |
+ |
if (periodicTask != null) |
|
131 |
+ |
ScheduledActionService.Remove(taskName); |
|
132 |
+ |
|
|
133 |
+ |
periodicTask = new PeriodicTask(taskName) { Description = "Periodic task to update the tile of <your app>." }; |
|
134 |
+ |
try |
|
135 |
+ |
{ |
|
136 |
+ |
ScheduledActionService.Add(periodicTask); |
|
137 |
+ |
//#if DEBUG_AGENT |
|
138 |
+ |
ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(10)); |
|
139 |
+ |
//#endif |
|
140 |
+ |
} |
|
141 |
+ |
catch (InvalidOperationException) { } |
113 |
142 |
|
} |
114 |
143 |
|
|
115 |
144 |
|
// Code to execute if a navigation fails |