How to kill whole application if child thread raises an exception?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 26 06:28:38 PDT 2016


On Wednesday, 26 October 2016 at 08:42:02 UTC, dm wrote:
> I want to kill all my threads if it is unhandled exception.
> How can I do that?

The spawnLinked function might help:

http://dpldocs.info/experimental-docs/std.concurrency.spawnLinked.html

http://dlang.org/phobos/std_concurrency.html#spawnLinked

" This new thread is linked to the calling thread so that if 
either it or the calling thread terminates a LinkTerminated 
message will be sent to the other, causing a LinkTerminated 
exception to be thrown on receive()."


At least that sounds basically right.


More information about the Digitalmars-d-learn mailing list