How to enumerate threads in .NET using the Name property?

前端 未结 4 814
-上瘾入骨i
-上瘾入骨i 2021-01-17 10:44

Suppose I start two threads like this:

// Start first thread
Thread loaderThread1 = new Thread(loader.Load);
loaderThread1.Name = \"Rope\";
loaderThread1.Sta         


        
4条回答
  •  不思量自难忘°
    2021-01-17 10:56

    I suspect you might have to put the threads into a Dictionary for that to work - but why do you want it anyway? There are usually other ways of communicating between threads (any of the lock / wait objects).

    To work at the process level (i.e. not thinking of the Thread object), see here - you could limit it to the current process, but you won't be able to interact with the thread.

提交回复
热议问题