LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CmtDiscardLock invalid handle

When I call CmtDiscardLock(read_lock) function I get -14901. Invalid handle.
read_lock value is 23047888 which I believe is a valid handle.
 
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 1 of 4
(3,610 Views)
Hi, test_man,

Just to clarify a few things. Where did you create this read_lock. Is it in the scope that when you call cmtdiscardlock you can see the handle? The handle is just an int so any integer could be perceived as a valid handle. It sounds like you're discarding the lock in the wrong scope. I would recommend a look at the example in \National Instruments\CVI81\samples\utility\Threading\ThreadedGuessers and see if it helps.

Song D
Regards,

Song Du
Systems Software
National Instruments R&D
0 Kudos
Message 2 of 4
(3,570 Views)
This is most probably happening because the lock has already been discarded by the same or another thread. One easy way to check and avoid this is to reset the lock variable's value to zero after discarding it using CmtDiscardLock, and discarding it only when it is not zero. A valid handle returned by a successful call to CmtNewLock is guaranteed to never be zero.
 
0 Kudos
Message 3 of 4
(3,568 Views)
Thanks Mohan. That helped. I discarded it somehere else and was trying to close it again but read_lock value was still positive number. So after I discarded it I assigned 0 to it.
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 4 of 4
(3,557 Views)