Disconnect Thread / Connection Methods

Where are the features of C # Thread Detach / Joinable ?

In C ++ 11, these functions are available:

 thread::joinable() thread::detach() 

But they cannot be found in .NET - where are they?

+6
source share
1 answer

What would make detach in your mind in .NET? .NET has no automatic storage duration. This concept does not apply.

joinable is not really applied because you can Join any thread, even Thread.Current . If you insist on C ++ semantics:

 Thread someThread = ...; bool isJoinable = Thread.Current != someThread; 

Thread objects are subject to garbage collection , but the thread ends, regardless of whether the Thread object is available. Do not worry about it.

+2
source

Source: https://habr.com/ru/post/974936/


All Articles