The threadpool was being shutdown too early, before the ProcessExit event was fired.
This led to bugs such as NLog not shutting down
(http://nlog-project.org/2011/10/30/using-nlog-with-mono.html).
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-ptr-array.h>
#include <mono/metadata/verify-internals.h>
+#include <mono/metadata/runtime.h>
#include <mono/io-layer/io-layer.h>
#include <mono/utils/strtod.h>
#include <mono/utils/monobitset.h>
{
MONO_ARCH_SAVE_REGS;
+#ifndef MONO_CROSS_COMPILE
+ mono_runtime_shutdown ();
+#endif
+
mono_threads_set_shutting_down ();
mono_runtime_set_shutting_down ();
#include <mono/metadata/monitor.h>
#include <mono/metadata/gc-internal.h>
#include <mono/metadata/marshal.h>
+#include <mono/metadata/runtime.h>
#include <mono/io-layer/io-layer.h>
#ifndef HOST_WIN32
#include <mono/io-layer/threads.h>
THREAD_DEBUG (g_message ("%s: I have %d threads after waiting.", __func__, wait->num));
} while(wait->num>0);
+#ifndef MONO_CROSS_COMPILE
+ mono_runtime_shutdown ();
+#endif
+
mono_threads_set_shutting_down ();
/* No new threads will be created after this point */
#endif
#ifndef MONO_CROSS_COMPILE
- mono_runtime_shutdown ();
/*
- * mono_runtime_cleanup() and mono_domain_finalize () need to
- * be called early since they need the execution engine still
- * fully working (mono_domain_finalize may invoke managed finalizers
- * and mono_runtime_cleanup will wait for other threads to finish).
+ * mono_domain_finalize () needs to be called early since it needs the
+ * execution engine still fully working (it may invoke managed finalizers).
*/
mono_domain_finalize (domain, 2000);
#endif