How to kill whole application if child thread raises an exception?
rikki cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Oct 26 02:43:10 PDT 2016
Basically when you spawn a thread giving the function, you pass it
through another function which will catch any exceptions not normally
caught.
Of course this really should be the default behavior but somebody else
may be more of a help here.
And it is pseudo code, so please don't expect it to 100% work as I have
written it.
```D
void entryPoint(alias func)() {
try {
func();
} catch (Exception e) {
import std.stdio;
writeln(e.toString());
}
}
void main() {
auto tid = spawn(&entryPoint!someFunc);
// ...
}
```
More information about the Digitalmars-d-learn
mailing list