ICorProfilerCallback::Shutdown Method

Notifies the profiler that the application is shutting down.

Syntax

HRESULT Shutdown();  

Remarks

The profiler code cannot safely call methods of the ICorProfilerInfo interface after the Shutdown method is called. Any calls to ICorProfilerInfo methods result in undefined behavior after the Shutdown method returns. Certain immutable events may still occur after shutdown; the profiler should take care to return immediately when this occurs.

The Shutdown method will be called only if the managed application that is being profiled started as managed code (that is, the initial frame on the process stack is managed). If the application started as unmanaged code but later jumped into managed code, thereby creating an instance of the common language runtime (CLR), then Shutdown will not be called. For these cases, the profiler should include in its library a DllMain routine that uses the DLL_PROCESS_DETACH value to free any resources and perform clean-up processing of its data, such as flushing traces to disk and so on.

In general, the profiler must cope with unexpected shutdowns. For example, a process might be halted by Win32's TerminateProcess method (declared in Winbase.h). In other cases, the CLR will halt certain managed threads (background threads) without delivering orderly destruction messages for them.

Requirements

Platforms: See System Requirements.

Header: CorProf.idl, CorProf.h

Library: CorGuids.lib

.NET Framework Versions: Available since 2.0

See also