This question has already been answered:

There is a stream, let it be a parent stream:

Thread Thread1 = new Thread(Void1); // Thread1 .Start(); 

Inside the parent there are N threads created, let there be children-flows. After creating the last thread inside the parent, I suspend the parent thread. and now I need to remove all the "children" without checking anything, just nail them. Is it possible to do something?

Reported as a duplicate by andreycha c # Nov 14 '17 at 15:56 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    for good, you can not kill the stream. You need to send them a message in some way asking them to close. And then everything is simple - the flow parent knows their descendants and send the message they need. - KoVadim

1 answer 1

No

First, the stream has no concept of a “child stream”. You cannot find the streams created by the data, except that you yourself when you create a new stream remember it in an accessible place.

Secondly, it is impossible to “kill” flows. Streams are obliged to cooperate, and end at the right moment. (Usually, CancellationToken used for such purposes.)