如何从异步 RIA 服务调用获取通知?

发布于 2024-09-11 15:12:44 字数 585 浏览 1 评论 0原文

我已经使用 RIA Services、Entity Framework 4 和 Silverlight 4 设置了一个应用程序。它是按照 MSDN 上规定的方式设置的:演练:创建 RIA 服务解决方案

在客户端,此代码将客户实体加载到网格的 ItemsSource 中

    public MainPage()
    {
        InitializeComponent();

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

:对“loadOp.Entities”的调用是异步完成的(由 RIA 服务自动完成)。异步调用完成后如何收到通知?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不回头走下去 2024-09-18 15:12:44

您需要使用回调。我还没有使用过RIA的正式版本,但是在测试版中它是这样使用的。

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
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文