Redaguoti

Bendrinti naudojant


ICorProfilerInfo4::InitializeCurrentThread Method

Initializes the current thread in advance of subsequent profiler API calls on the same thread, so that deadlock can be avoided.

Syntax

HRESULT InitializeCurrentThread ();  

Remarks

We recommend that you call InitializeCurrentThread on any thread that will call a profiler API while there are suspended threads. This method is typically used by sampling profilers that create their own thread to call the ICorProfilerInfo2::DoStackSnapshot method to perform stack walks while the target thread is suspended. By calling InitializeCurrentThread once when the profiler first creates the sampling thread, profilers can ensure that lazy per-thread initialization that the CLR would otherwise perform during the first call to DoStackSnapshot can now occur safely when no other threads are suspended.

Note

InitializeCurrentThread does the initialization in advance to finish tasks that take locks, and may deadlock. Call InitializeCurrentThread only when there are no suspended threads.

Requirements

Platforms: See System Requirements.

Header: CorProf.idl, CorProf.h

Library: CorGuids.lib

.NET Framework Versions: Available since 4.5

See also