D
D
dgash22012021-03-10 14:31:22
.NET
dgash2201, 2021-03-10 14:31:22

Why is there no detach method for threads in C# like in C++?

Can someone explain why C# doesn't have a method like detach for threads like C++ does?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BasiC2k, 2021-03-10
@dgash2201

I'm not a C++ expert, so please correct me if I'm wrong.
As far as I understand, detach in C ++ is needed to "detach" a child thread from the main one? Those. If the main thread terminates, does the child continue to run?
For Thread in C# there is a property IsBackground https://docs.microsoft.com/ru-ru/dotnet/api/system... maybe this is the analogue you need?

I
Ivan Volodin, 2021-03-10
@int_i

"There are two types of threads: foreground and background threads. Background threads are automatically terminated when the foreground threads finish"

--- Article
"We can change the types of threads ourselves. The IsBackground thread property determines whether the thread is in the background. Thus, we can make the thread a priority"

--- Same article

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question