Admin Production ni-theme
Current Publication

CmtGetLock

LabWindows/CVI

CmtGetLock

int CmtGetLock (CmtThreadLockHandle lockHandle);

Purpose

Note Note  This function has been superseded by CmtGetLockEx.

Gets ownership of the thread lock.

When you finish using the thread lock, you must release the lock by calling CmtReleaseLock from the same thread that called this function. Only one thread can get ownership of the thread lock at a time. If a thread requests the lock while another thread owns the lock, the calling thread waits in this function until the owning thread releases the lock. You can call this function from the same thread more than once, but you must call CmtReleaseLock once for each time that you called this function.

If you set the options parameter in the CmtNewLock function to OPT_TL_PROCESS_EVENTS_WHILE_WAITING, this function processes messages while waiting for the lock.

Parameters

Input
Name Type Description
lockHandle CmtThreadLockHandle The handle you obtained from CmtNewLock to identify the thread lock.

Return Value

Name Type Description
cmtStatus int The CmtStatus code that the function call returns. This function returns 0 to indicate success and negative values to indicate failure. Pass the CmtStatus code to CmtGetErrorMessage to get a description of the error code.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later

Examples

Refer to the following examples that use the CmtGetLock function:

  • utility\threading\ThreadedGuessers\ThreadedGuessers.cws

    Open example
  • utility\threading\ThreadPool\ParallelTestInit\ParallelTestInit.cws

    Open example