42 said:
However; it clearly says you can catch them directly by putting a
catch block "at the top of your non-main thread, threadpool workitem,
or finalizer".
Have you experimented with that? Why is that not suitable for your
needs??
Because it relies on the plugin programmer to do that. If I was the plugin
programmer, then none of this would be a problem because I would guarantee
to myself that I would wrap everything in a try/catch. But I can't make
that guarantee about other programmers.
This ties into why I'm trying to prevent the plugin from creating new
threads. Because if they don't create threads, then I can guarantee that
the plugin host can capture any exceptions. But if they DO create threads,
then I cannot do this.
As a totally different approach... have you considered running the
"plug-ins" in a completley separate process. Then they can crash and
burn without their child threads throwing unhandled exceptions back
into your host application.
Yeah I thought about it briefly... But I'm doing this for my own personal
gratification as anything else, and I want to "do it the right way". I'm
sure I could probably force things to work if I did it this way, but it
wouldn't feel right.
Incidentally, I've been playing around with the ADMHost sample that Naveen
pointed out, and I feel like I'm close to what I want... like it's on the
other side of a wall that I just have to figure how to get around. I'm
still trying to wrap my head around exactly what is going on in ADMHost,
and there are a few things that are confounding me. Shawn Farkas' ADMHost
modifications feel like the right way to go - I just haven't yet been
successful in integrating it with my plugins library.
Right now, I can create a version of my application that can create
threads, or I can create one that cannot create threads. I'm trying to
figure out how to let plugin host create threads but not the plugins
themselves. I'm getting closer.
Here's the ADMHost discussion just for reference:
http://blogs.msdn.com/shawnfa/archive/2005/10/13/480210.aspx
-mdb