Hi All,
I'm Using:
Labwindows CVI 7.0
Windows XP OS
I am having a problem with using threadlocking with CVI.
My code looks like the following:
****************************************************************************************
int myLock;
void main()
{
CmtNewThreadPool (1, &tPool);
CmtScheduleThreadPoolFunction (tPool, Thread, NULL, NULL);
CmtNewLock (NULL, OPT_TL_PROCESS_EVENTS_WHILE_WAITING, &myLock);
}
int CVICALLBACK do_Test (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_VAL_CHANGED:
CmtGetLock (myLock);//application freezes here
CmtReleaseLock (myLock);
break;
}
return 0;
}
****************************************************************************************
The callback do_Test is hooked up to a numerical knob control. When I try to turn the numerical knob, on the first increment, I get an EVENT_VAL_CHANGED event. Then as soon as I step through the code to the "CmtGetLock (myLock)" line, the application locks up ( as if it already had a lock applied to it that was never released). In fact I can't use the stop button on the compiler either, I have to use the 'Terminate Execution' command to close my application. I have tried this with the dial having a range of 1-10 and 1-2000 and the same problem occurs. I have tried this with a numerical dial as well and experienced the same results.
Am I doing something wrong here? If not, is there a known workaround for this? Using a lock on EVENT_COMMIT works fine, but that is not an option, I need a lock on EVENT_VAL_CHANGED.