Merge pull request #3473 from ntherning/fix-thread-double-close-handle-on-appdomain...
[mono.git] / mono / utils / mono-threads-windows.c
index 97f75f0db1e5544155933bf8846256723c9f8b36..d2b3b5e2ea357281d6e7b9ce9e47c6edf496e1d1 100644 (file)
@@ -296,12 +296,14 @@ mono_threads_platform_yield (void)
 void
 mono_threads_platform_exit (int exit_code)
 {
+       mono_thread_info_detach ();
        ExitThread (exit_code);
 }
 
 void
 mono_threads_platform_unregister (MonoThreadInfo *info)
 {
+       mono_threads_platform_set_exited (info);
 }
 
 int
@@ -352,6 +354,10 @@ mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
 void
 mono_threads_platform_set_exited (MonoThreadInfo *info)
 {
+       g_assert (info->handle);
+       // No need to call CloseHandle() here since the InternalThread
+       // destructor will close the handle when the finalizer thread calls it
+       info->handle = NULL;
 }
 
 void