Unlimited Possibilities through Code
I have a new app for the New Year on the Windows 8 App Store!
Disney Facts is a quick fun app for getting random facts about Disney Trivia, parks, movies, characters, quotes, and more.
Download Disney Facts on the Windows Store
Snapped view gives you the ability to have the facts on the side panel while continuing to work. I think I should add a playback mode to change the fact periodically while it is running in this mode, what do you think?
If you are interested in Disney and don’t care about the technical stuff, just use the link above to go get it from the app store. The rest of this article will include some technical information about he implementation of the app.
The first thing my friends asked me was if I ported this from Windows Phone. Well, not exactly. The facts are the same as the phone app. The backend Azure service that feeds these facts and allow me to periodically update them over the internet are all the same. That is about it.
UI design, well that is obvious. You have to redesign your UI for the much larger screen than on a phone.
Most of my code though was totally broken and would not compile for Windows 8. The majority of the code changes were required due to the async await pattern in .Net 4.5.
Now to be fair, the new pattern actually made the code much, much simpler. I has a ton of really ugly multi threaded code in the Windows Phone version to make the UI stay responsive. I spun off threads to do most of the work parts, but then has to marshal the data back to the main thread to update the UI. With the new .Net 4.5 code I didn’t need to do any of that! So I guess the good news is that you get to write simpler code, the bad news is that I already have a lot of more complicated code that I have to redo.
This is the routine I use to create a file from a resource. I had to totally redo it because things like the isolated storage routines are not the same on Windows Store apps. That along with the async requirements made me rewrite it. I followed the same pattern in the classes, but the underlying code looks very different.
public async Task CreateFileFromResource(string resourceName, string fileName = null)
var file =
new Uri(InitialDataResource + resourceName));
Windows.Storage.ApplicationDataContainer localSettings =
var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
string targetFile = fileName;
if (fileName == null)
targetFile = App.FactsTextFilename;
StorageFile disneyData = await localFolder.CreateFileAsync
catch (Exception ex)
This was a pleasant surprise to me. Downloading is now always async of course, but the code is actually much simpler than the previous delegate approach I had implemented.
The download routine went from 73 lines of code down to this.
HttpClient httpClient = new HttpClient();
HttpResponseMessage response = await
httpClient.GetAsync(AzureBaseUrl + "DisneyWorldFacts.json");
string responseData = await response.Content.ReadAsStringAsync();
return await WriteDisneyFacts(responseData);
That is a huge difference in readability of the code.
©2010-2012 Jason Short. All Rights Reserved. The opinions expressed herein are my own and do not represent my employer’s views in any way.