I need help with DataServiceCollection Class(http://msdn.microsoft.com/en-us/library/ee474331(v=vs.92).aspx) and LoadAsync() method(http://msdn.microsoft.com/en-us/library/ee652610(v=vs.95).aspx)
In MSDN documentation I found:”The LoadAsync method can be called only once on the UI thread. The method cannot be called again until after the LoadCompleted event is raised. The LoadCompleted event is raised whether or not the query succeeds.” I do the folowing
public void LoadCategories()
{
Categories = new DataServiceCollection<Category>(context);
Categories.LoadAsync(categoriesUri);
Categories.LoadCompleted += (sender, args) =>
{
if (args.Error != null)
{
Debug.WriteLine("Requesting pictures failed. " + args.Error.Message);
}
else
{
LoadNewPictures();
}
};
public void LoadNewPictures()
{
_newPictures = new DataServiceCollection<Picture>(context);
_newPictures.LoadAsync(picturesUri);
_newPictures.LoadCompleted += (sender, args) =>
{
if (args.Error != null)
{
Debug.WriteLine("Requesting pictures failed. " + args.Error.Message);
}
else
{
IsDataLoaded = true;
}
};
}
But it is not working I get only Categories collection. Can anybody help me?
For the scrore 🙂
Try assigning your LoadComplete event prior to calling LoadAsync. Maybe LoadAsync for some or other
reason returns immidiatly preventing your LoadCompleted from being called?