日期:2014-05-18  浏览次数:21110 次

关于WebService异步调用的问题
这两天做毕业项目,网站中有一个天气预报的功能,我在业务逻辑层的类库中添加了天气预报的Web Service 然后写方法将天气结果返回给网页,但是如果遇到网络问题或者其他的问题,我的网页打开速度就很慢或者直接就打不开,我想问一下在类库中怎么进行异步调用?或者用其他的方法可以解决上述问题,知道的麻烦指导一下,谢谢各位前辈啦。
C# code

public class WeatherManager
    {
        public string[] WeatherForecast(string city)
        {
            cn.com.webxml.www.WeatherWebService weather = new cn.com.webxml.www.WeatherWebService();
            return weather.getWeatherbyCityName(city);
        }
    }



------解决方案--------------------
C# code

new Thread(new ThreadStart(()=>{
// get weather
})).Start();