Posts

Showing posts from November, 2011

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

Image
This is a continuation of this post , explaining how the sample app works. Caution : This sample isn’t meant as an example of best patterns and practices. If you see something in the code you would never do, then don’t. Solution File Organization The app has three Visual Studio Projects: the app, the agent, and the shared code library between them. One of the great things about Mango is that now the built-in Visual Studio Unit test functionality is available. By separating out the meat of the work into the SampleShared project, I can also focus my unit testing there. SampleApp1 The app has a MainPage, a ViewModel, and the WMAppManifest.xml file modified to note my ExtendedTask of BackgroundServiceAgent. The Agent is extremely simple with a call to the shared library, an update to the Tile, and a call to pop up Toast. The meat of the work is in the SampleShared library. The AgentMgr manages the background agent : add, remove, find, run now. It is only called f...

A Simple WP7 Mango App for Background Tasks, Toast, and Tiles

Image
Download Binary and Code The .XAP binary and code solution are both available for download . The app uses a background process that does some work then updates the tile and pops up toast. The app and the agent talk to each other via an isolated storage file protected by a named mutex. The diagram below shows the pieces and how they work together. This is the app associated with this post . App/Agent Architecture The app and agent don’t actually talk to a web service as this is a sample but in a real world solution they both would. The app would do the heavy lifting. The agent would have a quick, light conversation with just enough information to update the tile and pop up toast with meaningful information. In this sample, you can configure the agent to run repetitively every minute, second, etc. This is usually done for debug/testing. In the usual release situation, the agent runs on the 30 minute cycle. Start the App Pin the App to the Start Screen Make...