So I have started writing the app.
I started with the base data application template. I haven't changed much yet just basically going for a proof of concept connecting to the EVE API. I started with the List of Characters.
Looking through the code I spotted LoadData() method with some sample data. I then looked at how I would get hold of the data from the EVE API. I played with the XMLReader but apparently it can only directly reference urls within the application, so I moved on to the WebClient class. I'm using the asynchronous DownloadStringAsync method with raises a DownloadStringCompleted event on completion of the download.
WebClient
client.DownloadStringCompleted +=
client_DownloadCharactersCompleted);
client.DownloadStringAsync( client = new WebClient();new DownloadStringCompletedEventHandler(new Uri("<Your URL here"));
I then used the XmlReader to parse the result adding items to the ListBox on the mainpage.
This worked will but as I was using an async call there was at times a delay when the data was being loaded. The fill this gap I looked at Progress Bars. Apparently the standard ProgressBar class when indeterminate, i.e. when you don't know how long it is going to run, is inefficent as it uses the wrong thread to be drawn. Microsoft recommends using a Custom Indeterminate Progress Bar. There are instructions on the link to incorporate it into your application.
I added the custom progress bar to the app, I did have to hack the LoadData() method to pass a reference to the Progress bar to the where the data is actually loaded but I sucessfully got the progress bar to show when the call was made and stop when the data was parsed and loaded to the MainPage.
I am not happy with this solution though and plan to fix it in the next post :)
No comments:
Post a Comment