LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

assistance needed for multithreading sample 'MultiPanel'

Solved!
Go to solution

Hi,

 

at present my data acquisition program consists of several floating panels, one is the 'main' panel, and then there are other 'instrument panels' that operate individual instruments (one panel per instrument type).

 

Now I have studied the sample 'multipanel' because I wanted to operate my 'instrument panels' in individual threads. I succeeded only partially. I can start the threads via CmtScheduleThreadPoolFunction, and run each panel using its own RunUserInterface. And I can quit the individual user interfaces by their respective 'quit' button.

 

What I can not do (and the NI sample doesn't do it either) is to automatically close all the individual instrument panels simply by closing the main panel. In the sample, the main panel may be closed, but the chart panel keeps running. How could it be achieved in the sample that by closing the main panel the chart panel quits, too?

 

Thanks a lot!

 

Wolfgang

0 Kudos
Message 1 of 5
(4,050 Views)
Solution
Accepted by topic author Wolfgang

Inside Multipanel sample, 'Exit function' button contains a function to terminate a thread from the main thread, so you can mimic this function behaviour to obtain your goal: terminating all secondary threads before teminating your application.


Take a look at the modified version of multipanel that I am attaching. I relied on NotifyThreadFunctionExecState () function which is used in the example to conveniently populate the list of active threads: I have added to it a active thread counter so that I am sure that all threads are effectively terminated before exiting the main thread.

Message Edited by Roberto Bozzolo on 04-18-2009 11:20 PM


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?
Message 2 of 5
(4,043 Views)

Hi Roberto,

 

I'll be able to look at your code only tomorrow, but let me thank you already now: providing a custom example is more than just nice: I really appreciate it a lot!

 

Wolfgang

0 Kudos
Message 3 of 5
(4,030 Views)
indeed, works as expected 🙂 Very nice! Thanks again.
0 Kudos
Message 4 of 5
(4,006 Views)
You're welcome!


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 5 of 5
(4,003 Views)