读书人

webservice 线程调用 返回值,该如何处

发布时间: 2013-11-27 21:59:41 作者: rapoo

webservice 线程调用 返回值



[WebMethod]
public string getInfo()
{
System.Threading.ThreadStart start = new System.Threading.ThreadStart(test);
System.Threading.Thread th = new System.Threading.Thread(start);
th.ApartmentState = System.Threading.ApartmentState.STA;
th.Start();


return obj;
}

void test()
{
string result=DateTime.Now.ToString();//详细代码实现
}


webservice中要返回 test 中的结果,不知道怎么处理

webservice 多线程
[解决办法]
线程中通知主进程用委托,google“C#线程委托”
[解决办法]
〉 webservice中要返回 test 中的结果

若是需要等待线程的结果, 就没必要用线程了

直接调用就好了。

读书人网 >asp.net

热点推荐