Returning a value from thread?

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

How do I return a value from a thread?

17条回答
  •  眼角桃花
    2020-11-27 10:22

    class Program
    {
        static void Main(string[] args)
        {
            string returnValue = null;
           new Thread(
              () =>
              {
                  returnValue =test() ; 
              }).Start();
            Console.WriteLine(returnValue);
            Console.ReadKey();
        }
    
        public static string test()
        {
            return "Returning From Thread called method";
        }
    }
    

提交回复
热议问题