Returning a value from thread?

前端 未结 17 2474
不思量自难忘°
不思量自难忘° 2020-11-27 09:45

How do I return a value from a thread?

17条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 10:19

    Can use This Code:

     private Object MyThread(Object Data)
          {
            Object response = null;
            Thread newThread = new Thread(() =>
            {
                response = MyFunction(Data);
                //MyFunction Is Function that you Define
            });
            newThread.Start();
            newThread.Join();
            return response;
          }
    

提交回复
热议问题