This is a Windows Phone7 project.
I have a few async calls in my code, that in the end, fills up a List that is global. But my problem is, how do I know when the async jobs is done, so that I can continue in the code?
EDIT I updated the code:
private void GetFlickrPhotos(Action finishedCallback)
{
Action<FlickrResult<PhotoCollection>> getPhotoCollectionCallback;
getPhotoCollectionCallback = GetPhotoCollection;
flickr.InterestingnessGetListAsync(getPhotoCollectionCallback);
finishedCallback();
}
private void GetPhotoCollection(FlickrResult<PhotoCollection> photoColl)
{
PhotoCollection photoCollection = (PhotoCollection)photoColl.Result;
foreach (Photo photo in photoCollection)
{
flickrPhotoUrls.Add(photo.MediumUrl);
}
}
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
GetFlickrPhotos(() =>
{
int test = flickrPhotoUrls.Count;
});
}
The async calls is done using Action<T> in .net framework 4. It still doesn’t wait for the async call. Is it because the async call is done from “GetFlickrPhotos”?
I went for the following code, it’s working for my program. Thank you for the help!
This way, I call the method
ShowPhotos()when the Flickr call is finished.