В файле MainPage.xaml.cs я создаю экземпляр альбома следующим образом:
Код: Выделить всё
Album album = new Album(2012); //With the album ID as its parameter.
ListView1.ItemsSource = album.Songs;
Код: Выделить всё
public Album(int ID)
{
this.ID = ID;
Initialize(); //Serves as a wrapper because I have to call httpClient.GetStreamAsync() and "async" doesn't work for the constructor.
}
Код: Выделить всё
private async void Initialize()
{
//...some code...
HttpClient cli = new HttpClient();
Stream SourceStream = await HttpClient.GetStreamAsync("http://contoso.com");
//...some code...
this.Songs = Parse(SourceStream);
}
Есть ли быстрое решение этой проблемы?
Подробнее здесь: https://stackoverflow.com/questions/122 ... on-of-call
Мобильная версия