Platform SDK: Exchange Server

HrMonLockCounters

The HrMonLockCounters function locks the counters against modification by another thread or process.

Quick Info

Header file: MONITOR.H
Library: MONITOR.LIB

HRESULT HrMonLockCounters(
  VOID  
);
 

Parameters

None.

Return Values

See Return Values.

Remarks

Use HrMonLockCounters to gain exclusive access to the counters before modifying a user-defined counter.

When a user-defined counter is specified in a COUNTERDEF structure in the call to HrMonInit, a pointer to the actual user-defined counter is returned to the user. This user-defined counter is located in a section of memory that is shared between multiple processes. HrMonLockCounters and HrMonUnlockCounters synchronize access to these counters. For example:

_int64 *UserCounter1, *UserCounter2;
...
HrMonLockCounters();
*UserCounter1++;
*UserCounter2 += cBytes;
HrMonUnlockCounters();
...
 

After calling HrMonLockCounters you must always call HrMonUnlockCounters. Otherwise, the gateway and the Windows NT Performance Monitor can hang. To improve performance, don't put time-consuming processing between the calls to HrMonLockCounters and HrMonUnlockCounters.

For more information on this function, see Monitor Sampling Functions and the HrMonLockCounters function in MONITOR.C under the MONITOR code sample in Code Samples folder.

See Also

HrMonUnlockCounters