- if (!finalizer_thread_exited) {
- /* Set a flag which the finalizer thread can check */
- suspend_finalizers = TRUE;
- mono_gc_suspend_finalizers ();
-
- /* Try to abort the thread, in the hope that it is running managed code */
- mono_thread_internal_abort (gc_thread);
-
- /* Wait for it to stop */
- ret = guarded_wait (gc_thread->handle, 100, TRUE);
-
- if (ret == MONO_THREAD_INFO_WAIT_RET_TIMEOUT) {
- /*
- * The finalizer thread refused to exit. Make it stop.
- */
- mono_thread_internal_stop (gc_thread);
- ret = guarded_wait (gc_thread->handle, 100, TRUE);
- g_assert (ret != MONO_THREAD_INFO_WAIT_RET_TIMEOUT);
- /* The thread can't set this flag */
- finalizer_thread_exited = TRUE;