Reputation: 681
I really need your help since I have a frustrating problem. I'm downloading data in my periodic agent (OnInvoke). Works fine but every night the web site I download data from has no data to download. If that happens I want the live tile to remain as it is (instead of beeing empty) with the current data and not get updated. Then one or two hours later when there is data to download and parse the update should continue.
I have tried this but when NotifyComplete is called the the code after still gets executed. Isn't NotifyComplete supposed to stop the rest of the code to be executed?
MatchCollection matchesMyData = rxMyData.Matches(strHTML);
foreach (Match matchMyData in matchesMyData)
{
GroupCollection groupsMyData = matchMyData.Groups;
//Code for handling downloaded data
}
if (matchesMyData.Count < 1)
{
ShellToast toast = new ShellToast();
toast.Title = "No update: ";
toast.Content = "Webservice returned no data";
toast.Show();
NotifyComplete();
}
I also tried the following peice of code but that stopped my background task and I had to start my app again to re-enable it. Why?
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("TileID=2"));
if (TileToFind != null && intCount > 0)
{
//Update the live tile
}
So, when no data gets parsed the tile should remain as it is and an hour or two later when data gets downloaded everything should be back to normal with thetile beeing updated.
Please help, since this is a show stopper right now. Thanks in advance.
Upvotes: 3
Views: 305
Reputation: 1580
Calling NotifyComplete() will not stop the code after the method call being executed, it just lets the OS know that you are finished. The OS should abort the thread but there may be time for a few more lines of code to run (the documentation isn't clear on whether the thread that calls NotifyComplete will be aborted immediately).
If you add a return statement after the call to NotifyComplete then the tile shouldn't be updated.
Upvotes: 2