LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CmtReleaseThreadPoolFunctionID should be used to stop a thread or not?

I'm trying to improve my understanding of multithreading by studying some of the CVI examples. 

 

I notice in the CVI Help page for CmtReleaseThreadPoolFunctionID() the following statement: "This function does not ... interrupt a Thread Function that ... is currently executing.", whereas, in the example IncrementValue.cws, it is explicitly used to do just that!  (In CVICALLBACK StopButtonCallback().)  This is probably a semantic issue or just confusion on my part. 

 

Please help me understand.

 

Thanks very much.

 

 

0 Kudos
Message 1 of 3
(3,397 Views)

The mechanism is not exactly what you have depicted: the first thing that StopButtonCallback does is setting running = 0: this makes the scheduled functions to stop (note the while (running) loop that encloses all function body). The stop callback then frees the function IDs, that are to be freed since CmtScheduleThreadPoolFunction has reserved them.

The function IDs are needed to permit CmtWaitForThreadPoolFunctionCompletion to wait for function completion before exiting the program.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,392 Views)

Roberto,

 

So it was the latter - confusion on my part!  Thanks for the quick reply!

 

Joe

0 Kudos
Message 3 of 3
(3,382 Views)