Compartilhar via


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
);

Parameters

  • cookie
    [in] The cookie associated with the monitor.

  • ppOwnerHostTask
    [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.

Remarks

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.

NoteNote:

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.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: MSCorEE.idl

Library: Included as a resource in MSCorEE.dll

.NET Framework Version: 2.0

See Also

Concepts

ICLRSyncManager Interface

IHostSyncManager Interface