开发者

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

开发者 https://www.devze.com 2023-01-08 18:01 出处:网络
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

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

精彩评论

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

关注公众号