日期:2014-05-17  浏览次数:20428 次

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  中的结果

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

直接调用就好了。