@@ -426,33 +426,36 @@ extern "C" UINT64 QCALLTYPE ThreadNative_GetCurrentOSThreadId()
426426 return threadId;
427427}
428428
429- FCIMPL1 ( void , ThreadNative::Initialize, ThreadBaseObject* pThisUNSAFE )
429+ extern " C " void QCALLTYPE ThreadNative_Initialize (QCall::ObjectHandleOnStack t )
430430{
431- FCALL_CONTRACT ;
431+ QCALL_CONTRACT ;
432432
433- THREADBASEREF pThis = (THREADBASEREF) pThisUNSAFE ;
433+ BEGIN_QCALL ;
434434
435- HELPER_METHOD_FRAME_BEGIN_1 (pThis );
435+ GCX_COOP ( );
436436
437- _ASSERTE (pThis != NULL );
438- _ASSERTE (pThis->m_InternalThread == NULL );
437+ THREADBASEREF threadRef = NULL ;
438+ GCPROTECT_BEGIN (threadRef)
439+ threadRef = (THREADBASEREF)t.Get ();
440+
441+ _ASSERTE (threadRef != NULL );
442+ _ASSERTE (threadRef->GetInternal () == NULL );
439443
440444 // if we don't have an internal Thread object associated with this exposed object,
441445 // now is our first opportunity to create one.
442- Thread *unstarted = SetupUnstartedThread ();
443-
446+ Thread* unstarted = SetupUnstartedThread ();
444447 PREFIX_ASSUME (unstarted != NULL );
445448
446- pThis ->SetInternal (unstarted);
447- pThis ->SetManagedThreadId (unstarted->GetThreadId ());
448- unstarted->SetExposedObject (pThis );
449+ threadRef ->SetInternal (unstarted);
450+ threadRef ->SetManagedThreadId (unstarted->GetThreadId ());
451+ unstarted->SetExposedObject (threadRef );
449452
450453 // Initialize the thread priority to normal.
451- pThis ->SetPriority (ThreadNative::PRIORITY_NORMAL);
454+ threadRef ->SetPriority (ThreadNative::PRIORITY_NORMAL);
452455
453- HELPER_METHOD_FRAME_END ();
456+ GCPROTECT_END ();
457+ END_QCALL;
454458}
455- FCIMPLEND
456459
457460// Return whether or not this is a background thread.
458461FCIMPL1 (FC_BOOL_RET, ThreadNative::GetIsBackground, ThreadBaseObject* pThisUNSAFE)
0 commit comments