03-15-2016 02:41 AM
Hello Roberto,
I'm sory i can't put the whole code because it's confodential for a company.
1--Who is in charge of issuing the popup panel for serial number input and when (at test start, at test end...)?
>>>at the beginnig of the two function "CVICALLBACK test1ThreadFunction & CVICALLBACK test2ThreadFunction" a panel appear to put the serial number.
2--What is the program supposed to do when test for DUT 1 ends? And when DUT2 terminates?
>>>when one thread ends the panel appears to put the serial number then the test starts again.
When the first DUT and the second one still runnig i have to put the serial thne the test continue.
Yes i want test to execute independently, each with its proper timing (parallel test) .
If i do not wait for thread completion inside a control callback, so i delete it?
I modify the startfunction Callback :
int CVICALLBACK Start_Test (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
while (1)
{
CmtNewThreadPool(2,&handle);
CmtScheduleThreadPoolFunction (handle , test1ThreadFunction,0, &functionId);
CmtScheduleThreadPoolFunction (handle , test2ThreadFunction,0, &functionId2);
CmtReleaseThreadPoolFunctionID (handle , functionId);
CmtReleaseThreadPoolFunctionID (handle , functionId2);
CmtDiscardThreadPool (handle );
}
}
return 0;
}
But it still wait until the second test ends.
Thanks for you help.
03-15-2016 03:30 AM - edited 03-15-2016 03:35 AM
I'm not interested in the complete code, I asked for the minimum that exposes the behaviour we are discussing, stripping out all proprietary code and everything not related to handling the threads. Sometimes it happens that creating such a minimum framework things work correctly and you get yourself some some clues on how to modify the real app. Anyway...
First of all, CmtWaitForThreadPoolFunctionCompletion is not mandatory! You can use it in some part of the program to check that thread ended before doing someting; tipically, it is issued at program end to be sure that all allocated threads are terminated before ending.
If I understand your scenario, you start testing function and then tests proceed in their own threads, so your start callback could terminate immediately after launching the threads.
I suppose you will have a button to stop testing: inside this button's callback you can issue the command to terminate the threads and wait for their completion before clearing resources and terminating the function.
03-15-2016 03:53 AM
Hello Roberto,
I know that im disturbing you i'm sorry.
I'll try to make some condition in my code to let the test works well.
Anyway, thanks a lot for your help 🙂