【发布时间】:2011-03-16 13:11:55
【问题描述】:
我有一个 web 服务正在运行,它的一个方法在调用时不会立即返回。它有数据时返回。一旦它返回,客户端再次调用它,以便在服务有数据时向客户端提供数据。这是为了避免轮询。但问题是,它在模拟器中运行良好,而在设备中虽然 webservie 没有返回,客户端最终在下面的函数中导致空异常。
public string Endgetstatus(System.IAsyncResult result)
{
object[] _args = new object[0];
string _result = ((string)(base.EndInvoke("getstatus", _args, result)));
return _result;
}
这就是我调用异步函数的方式,该函数在有数据时返回,否则不会返回。
client.getstatusCompleted += new EventHandler<getstatusCompletedEventArgs>(updatereceived);
client.getstatusAsync();//this returns only when it has data
设备是否在一段时间后终止任何打开的连接并强制客户端调用 Endgetstatus 函数?我已将超时设置为 23 小时
BasicHttpBinding binding= new System.ServiceModel.BasicHttpBinding();
TimeSpan interval = new TimeSpan(23, 14, 18);
binding.ReceiveTimeout = interval;
binding.SendTimeout = interval;
一分钟后客户端结束
public string Endgetstatus(System.IAsyncResult result) {
虽然 web 服务没有返回,但导致参数 null 异常。
谁能让我知道我应该怎么做才能在设备上工作,因为它在模拟器上运行良好?
请注意这里关于 windows phone 7 和 silverlight c#
【问题讨论】:
标签: c# web-services windows-phone-7