开发者

How do I get notifications from an asynchronous RIA Services call?

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 Items开发者_如何学PythonSource:

    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?


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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜