Returning a value from thread?

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

How do I return a value from a thread?

17条回答
  •  死守一世寂寞
    2020-11-27 10:38

    ThreadStart delegates in C# used to start threads have return type 'void'.

    If you wish to get a 'return value' from a thread, you should write to a shared location (in an appropriate thread-safe manner) and read from that when the thread has completed executing.

提交回复
热议问题