.NET Is there a way to get the parent thread id?

后端 未结 4 1274
一向
一向 2020-12-03 15:57

Suppose the main thread is spawning a new thread t1, how can my code that runs on t1 find the thread id of the main thread (using c#)?

Edit:
I don\'t control the

4条回答
  •  庸人自扰
    2020-12-03 16:39

    You can't.

    Yet you might consider:

    1. Prefix the name of the new thread with the thread ID from the parent thread
    2. Create a constructor on the method you want to spawn that requires the thread ID from the parent

提交回复
热议问题