【问题标题】:DataContext IsLoading InvokeOperationDataContext IsLoading 调用操作
【发布时间】:2011-04-06 11:11:10
【问题描述】:

我想知道是否有任何方法可以订阅一个事件,该事件会告诉我 InvokeOperation 是否在给定的 DomainContext 上忙。与 IsLoading 完全一样(在 InvokeOperation 上不会触发)。目前我得到了:

DomainContext.PropertyChanged += (c1, c2) =>
                {
                    IsBusy = (DomainContext.IsLoading && DomainContext.IsSubmitting);
                };

【问题讨论】:

    标签: c# silverlight wcf-ria-services


    【解决方案1】:

    1) 您提供的代码需要检查更改的属性名称

    DomainContext.PropertyChanged += (c1, c2) =>
                    {
                      if(c2.PropertyName == "IsLoading" || c2.PropertyName == "IsSubmitting")
                        IsBusy = (DomainContext.IsLoading && DomainContext.IsSubmitting);
                    };
    

    2)DomainContext 不提供调用操作的标志。但您始终可以自己设置。

    IsBusy = true;
    DomainContext.InvokeMyOperation(c=>
                                        {
                                          //in callback
                                          IsBusy = false;
                                        });
    

    【讨论】:

    • 谢谢,我还没有检查 (c2.PropertyName == "IsLoading" || c2.PropertyName == "IsSubmitting") 因为我有一个断点,我想看看在我的域上下文中调用什么属性。此外,第 (2) 点是我正在做的事情,但我不想每次调用某些东西时都设置 IsBusy 属性,但有可能不会在某处设置它,或者当抛出异常时,它仍会将 IsBusy 设置回 false
    • 如果发生异常回调仍将被调用,您可以取消设置繁忙标志。为避免健忘,您可以将此代码包装到服务类中。
    • 谢谢,我希望有一种更简单的方法,我不明白为什么不使用 InvokeOperations 调用 IsLoading 属性
    猜你喜欢
    • 2012-01-20
    • 1970-01-01
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    • 2019-06-29
    相关资源
    最近更新 更多