I have what I think is a rather complex problem. I have a C# application that utilizes a plug-in architecture using reflection. The application loads plug-in dlls and the user is able to enable/disable them. When a plug-in is enabled, the main app starts a thread to run the plug-in in. In many cases the plug-in may have multiple threads of its own. When I want to disable a plug-in I am calling Thread.Abort(). This seems to kill the initial thread that was created for the plug-in, but any additional threads that the plug-in created continue running. Is there a better way to stop all of the associated plug-in’s threads along with the main thread?
Thanks.
Don’t use
Thread.Abortfor this purpose.Add a
Shutdownmethod or similar to your plugin API and ask your plugins to shutdown cleanly. If you need to protect yourself against rogue plugins that refuse to shutdown then run them in their own AppDomain and kill the AppDomain if necessary.