I am writing application on WP 8.1. One of my method is parsing html and everything was ok. But I want to change coding to have polish characters. So I must to have Length properties to variable type byte[]. To make this possible I need to use await and changed my method on asnych.
public async void GetTimeTable(string href, int day)
{
string htmlPage = string.Empty;
using (var client = new HttpClient())
{
var response = await client.GetByteArrayAsync(URL);
char[] decoded = new char[response.Length];
for (int i = 0; i < response.Length; i++)
{
if (response[i] < 128)
decoded[i] = (char)response[i];
else if (response[i] < 0xA0)
decoded[i] = '\0';
else
decoded[i] = (char)iso8859_2[response[i] - 0xA0];
}
htmlPage = new string(decoded);
}
// further code... and on the end::
TimeTableCollection.Add(xxx);
}
public ObservableCollection<Groups> TimeTableCollection { get; set; }
Method is calling from MainPage.xaml.cs
vm.GetTimeTable(navContext.HrefValue, pivot.SelectedIndex);
TimeTableViewOnPage.DataContext = vm.TimeTableCollection;
And now is my question. Why vm.TimeTableCollection is null? When I don't use async and await everything is ok and vm.TimeTableCollection has x elements.