LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

multithreading: invalid function ID

Sorry, but I am still struggling with multithreading questions...

 

As mentioned before, I create a thread pool, and every thread in this pool will run its own instrument with its own RunUserInterface. Now, there are several ways to shut down the application: close the panels individually, then shut the main program down, or close the main program, which then will have to finish all the secondary threads internally.

For this purpose, in the quitting rotuine of the main program, I first determine the number of threads that have been running (not all instruments are opened every time). Some of the instrument panels might have been finished by closing the panels individually. So I thought to loop through the thread functions to find out which is still executing by determining its ATTR_TP_FUNCTION_EXECUTION_STATUS. Unfortunately, it doesn't work this way: if the secondary threads (instruments) have been closed and the main program is shut down, I receive the error 'invalid function ID' when calling CmtGetThreadPoolFunctionAttribute to obtain the execution status.

 

As I understood, the thread functions should still be there, sitting in the pool and either execute a function, or wait... So how can it be that the function ID got invalid?

 

Thanks!

 

Wolfgang

0 Kudos
Message 1 of 2
(3,251 Views)

That's strange, I use this function in the project I'm currently working on and it correctly tells me the correct state of the thread function, whether executing or not.

 

Are you sure you have defined the thread function ID as a variable accessable by the CmtGetThreadPoolFunctionAttribute and it is correctly initialized in  CmtScheduleThreadPoolFunction(Adv)?

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 2
(3,241 Views)