This documentation is archived and is not being maintained.

ICLRSyncManager::GetMonitorOwner Method

Gets the IHostTask instance that owns the monitor identified by the specified cookie.

HRESULT GetMonitorOwner (
    [in]  SIZE_T     cookie,
    [out] IHostTask *ppOwnerHostTask


[in] The cookie associated with the monitor.


[out] A pointer to the IHostTask that currently owns the monitor, or null if no task has ownership.




GetMonitorOwner returned successfully.


The CLR has not been loaded into a process, or the CLR is in a state in which it cannot run managed code or process the call successfully.


The call timed out.


The caller does not own the lock.


An event was canceled while a blocked thread or fiber was waiting on it.


An unknown catastrophic failure occurred. When a method returns E_FAIL, the CLR is no longer usable within the process. Subsequent calls to hosting methods return HOST_E_CLRNOTAVAILABLE.

The host typically calls GetMonitorOwner as part of a deadlock-detection mechanism. The cookie is associated with a monitor when it is created by using a call to IHostSyncManager::CreateMonitorEvent.


A call to release the event underlying the monitor might block—but will not deadlock—if a call to this method is currently in effect on the cookie associated with that monitor. Other tasks might also block if they attempt to acquire this monitor.

GetMonitorOwner always returns immediately and can be called any time after a call to CreateMonitorEvent. The host does not need to wait until a task is waiting on the event.

Platforms: See .NET Framework System Requirements.

Header: MSCorEE.h

Library: Included as a resource in MSCorEE.dll

.NET Framework Versions: 4, 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0