日期:2014-05-19  浏览次数:20456 次

WebServices异步调用的问题
System.Console.ReadLine();
System.IAsyncResult   Result;
System.Console.WriteLine( "异步调用开始 ");
Result=asy.BeginShow(i,null,null);
//我异步的调用一个webService     休眠输入一秒,如果把while改为if会输出一个点后返回应该返回的结果,但是如果是while,为什么就会不停的输出点

//这是我webService中的代码
/*[WebMethod]
public   string   Show(int   WaitTime)
{
if(WaitTime> 0)
{
System.Threading.Thread.Sleep(WaitTime*1000);
}
return   "这个调用的方法已经结束 ";
}*/


while(!Result.IsCompleted)
{
System.Console.Write( ". ");
}
string   AsyTemp=asy.EndShow(Result);
System.Console.WriteLine(AsyTemp+ "\n异步调用结束 "+Result.IsCompleted);
System.Console.ReadLine();

------解决方案--------------------
怎么看不明白,代码是不是没写全啊!
------解决方案--------------------
肯定出不来的,
在循环里须要去改变条件值,条件值在期间没发生变化,条件一值为真。当然就一下打点。