为来自 Silverlight 3 客户端的 WCF RIA 服务调用配置超时 [英] Configuring the timeout for a WCF RIA Services call from a Silverlight 3 client

查看:20
本文介绍了为来自 Silverlight 3 客户端的 WCF RIA 服务调用配置超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WCF RIA 服务测试版 使用 Silverlight 3.0,我希望能够从客户端配置超时.我知道底层技术是 WCF,并且默认超时似乎是我预期的 60 秒.

I'm using the WCF RIA Services Beta with Silverlight 3.0 and I want to be able to configure the timeout from the client. I know that the underlying technology is WCF and the default timeout seems to be 60 seconds as I would expect.

是否有一种简单的方法可以控制此设置和其他 WCF 设置?

Is there an easy way to control this and other WCF settings?

我的第一个想法是尝试 DomainContext OnCreated 挂钩点,在 RIA 服务进行测试之前可用的 RIA 服务概述 pdf 文件中提到.DomainContext<的 MSDN 文档/a> 对象不再提及该方法,尽管它仍然存在?我不确定这是文档滞后的情况还是表明我不应该使用此扩展点.

My first thought is to try the DomainContext OnCreated hook point which was mentioned in the RIA Services Overview pdf file that was available prior to RIA Services going beta. The MSDN documentation for the DomainContext object no longer mentions the method although it is still there? I'm not sure if this is a case of the documentation lagging behind or an indication that I shouldn't use this extensibility point.

namespace Example.UI.Web.Services
{
    public sealed partial class CustomDomainContext
    {
        partial void OnCreated()
        {
            // Try and get hold of the WCF config from here
        }
    }
}

推荐答案

http://blogs.objectsharp.com/CS/blogs/dan/archive/2010/03/22/changed-timeouts-in-wcf-ria-services-rc.aspx

域上下文创建后的任意一行:

Either one line after domain context creation:

((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);

或部分类

public partial class LibraryDomainContext
{
   partial void OnCreated()
   {
      if(DesignerProperties.GetIsInDesignMode(App.Current.RootVisual))
         ((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
   }
}

这篇关于为来自 Silverlight 3 客户端的 WCF RIA 服务调用配置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆