Burhan Ayan
Burhan Ayan

Reputation: 23

Windows Azure Mobile Services Data Fetching Completed

I can fetch my data using Windows Azure Mobile Services. What I want to do is to put a "Loading..." into my app. Before I can do it, I must know when the data fetching is completed.

The question is "How do I know this?"

Thanks in advance,

Some Code

private MobileServiceCollection<TodoItem, TodoItem> items;
private IMobileServiceTable<TodoItem> itemTable = App.MobileService.GetTable<TodoItem>();
items = await itemTablosu.Where(todoItem => todoItem.Complete == false).ToCollectionAsync();

Upvotes: 2

Views: 163

Answers (1)

Peter Ritchie
Peter Ritchie

Reputation: 35881

After the ToCollectionAsync "returns" is when it's done. Use of await builds up a state machine that executes the next line asynchronously on the UI thread when that operation is completed. You should only need to do something like:

items = await itemTablosu.Where(todoItem => todoItem.Complete == false).ToCollectionAsync();

myLoadingControl.Visibility = Visibility.Collapsed;

This assumes that ToCollectionAsync() is called from the UI thread (e.g. a button click, a Loaded handler, an OnNavigatedTo override, etc.

Upvotes: 1

Related Questions