LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check whether a CVI thread is closed successfully

I have a DLL that uses the CMT-functions for multithreading.
 
In order to monitor the thread handling I use Taskinfo.
 
The DLL is called in TestStand and shows a popup panel in a new thread(CVI thread). In TaskInfo I can identify the thread by threadId or window name (caption name).
As soon as I close the thread TaskInfo changes the window name to "class:CVIRTLVFrame4194304". Why?
 
The thread seams to continue running (State=WaitUser) with that new name until I close TestStand.
 
If I start the sequence again the number of threads in TaskInfo increases until 6 threads called "class:CVIRTLVFrame4194304" run. At the 7th run of the sequence the first thread called "class:CVIRTLVFrame4194304" is replaced, so that there are no more than 6 threads called "class:CVI...."
 
Why is this behaviour?
 
What happens to the thread? Is it still running or is it closed and only waits for the CVI RTE to be closed??
 
 
 
0 Kudos
Message 1 of 4
(4,563 Views)

 Hello MaWie,

One reason could be that the DLL is kept in memory because of the "Load Options" within TestStand.

So i would recommend to change the "Unload Option" of the regarding step to "Unload after step executes" by right-clicking the step>Properties>Run Options

Regards, Christian

0 Kudos
Message 2 of 4
(4,534 Views)
In the CVI multithreading functions, threads belong to thread-pools and are discarded only when the thread-pool is discarded. So if you create your own thread-pool, you should call CmtDiscardThreadPool after you are done using the threads, and this should discard your threads. The default thread pool should not be explicitly discarded - CVI will discard it when the process exits. So you should avoid using the default thread pool in DLLs if you want to explicitly discard the threads. In general, using the default thread pool is not recommended in DLLs because you end up sharing the same pool with other DLLs - there is only one default thread pool per process.
0 Kudos
Message 3 of 4
(4,522 Views)
You are right, as soon as I have discarded the thread pool with CmtDiscardThreadPool the threads are closed (and disapear from TaskInfo).
Now I monitor the number of threads and number of active threads with CmtGetThreadPoolAttribute(pool, ATTR_TP_NUM_THREADS, &numThreads) and CmtGetThreadPoolAttribute(pool, ATTR_TP_NUM_ACTIVE_THREADS, &numActiveThreads).
 
Thanks for your help.
0 Kudos
Message 4 of 4
(4,501 Views)