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.

Return Value

HRESULT Description
S_OK GetMonitorOwner returned successfully.
HOST_E_CLRNOTAVAILABLE 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.
HOST_E_TIMEOUT The call timed out.
HOST_E_NOT_OWNER The caller does not own the lock.
HOST_E_ABANDONED An event was canceled while a blocked thread or fiber was waiting on it.
E_FAIL 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 System Requirements.

Header: MSCorEE.h

Library: Included as a resource in MSCorEE.dll

.NET Framework Versions: Available since 2.0

See Also

ICLRSyncManager Interface
IHostSyncManager Interface