Hi ! I've done a program that communicates using serial interface. I divided the program in three threads: one for the UI, another for a timer (asynchronous timer) and the last one communicates to serial port. In this last thread I use many 'if statements' on some flags (which can be modified by the other two threads), so I created a thread lock to lock these variables during the execution of the if statement:
CmtGetLock (thread_lock);
if (flag.data_ready)
{
...
}
CmtReleaseLock (thread_lock);
CmtGetLock (thread_lock);
if (flag.wait_data)
{
...
}
CmtReleaseLock (thread_lock);
.
.
.
Everything seems working very well, but when I close the program, it hangs on the command
CmtDiscardLock (thread_lock);
I called this
function after CmtWaitForThreadPoolFunctionCompletion.
The only solution is to close the program from task manager.
Where is the error ?
Thank you !