How Stop Worker Thread if Owner Thread is Finished?

Anonymouse zorael at gmail.com
Tue Oct 27 09:36:26 UTC 2020


On Tuesday, 27 October 2020 at 08:33:36 UTC, Johann Lermer wrote:
> or you could use the fact, that receiveTimeout throws an 
> exception, when main ends (although I don't know if this is the 
> intended behaviour; the manual just says that it throws an 
> exception when the sending thread was terminated):

If you're receiving you can listen for an OwnerTerminated message.

bool shouldExit = receiveTimeout((-1).seconds,
     (OwnerTerminated o) {}
);

https://run.dlang.io/is/2t50yS


More information about the Digitalmars-d-learn mailing list