How to gracefully unload a child AppDomain that has threads running

痞子三分冷 提交于 2019-12-05 05:47:56
DiVan

Try the following

runnerThread.IsBackground = true;

And, yeah, there is no graceful unloading of AppDomain if you didn't stop the threads first.

The situation is essentially the same as if the two AppDomains were separate processes, so you need to use some form of IPC. One option would be to pass an event handle into the child AppDomain when asking the loop to stop. The loop can signal the event before exiting. Wait for the event to give the loop some time to finish. If you time out, then you can do a rough unload.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!