views:

93

answers:

1

I've got an application set up with RIA Services, Entity Framework 4, and Silverlight 4. It is set up in the fashion prescribed on MSDN here: Walkthrough: Creating a RIA Services Solution

On the client side, this code loads the customer entities into a grid's ItemsSource:

    public MainPage()
    {
        InitializeComponent();

        LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery());
        CustomerGrid.ItemsSource = loadOp.Entities;
    }

The call to "loadOp.Entities" is done asynchronously (automatically by RIA Services). How do I get notification when the asynchronous call is complete?

A: 

You need to use a callback. I haven't used the official release of RIA yet, but in the beta it was used like so.

public MainPage()
{
    InitializeComponent();

    LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery(),MyCallback,null);
    CustomerGrid.ItemsSource = loadOp.Entities;
}

private void MyCallback(LoadOperation<Customer> loadOperation)
{
    //This will be called when the load is complete
}
Stephan
Thanks, just what I was looking for. There is an additional argument requireed for Load in the released version of RIA Services, e.g. this._customerContext.Load(this._customerContext.GetCustomersQuery(),MyCallback, null);
sparks
Yeah I forgot the `objectState` argument. That's a pretty standard argument on async calls in all of .NET.
Stephan