LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

panels and multithreading - which panel functions can I call from another thread.

Solved!
Go to solution

I am writing a program (Windows XP, LabWindows/CVI 2010) that has multiple threads. The main thread generates and handles most of the panels, but not all. Is there a listing of which panel functions are thread safe and which are not? From reading the help file and the various posts, the set-value functions are safe; the set-attribute functions are NOT. (I found that calling SetPanelAttribute () with ATTR_TITLE will definitely lock up a program!). How about calliing a control callback function? (Via the CallCntrlCallback() function). It seems to be working fine so far, but I can't find anything definitive.

0 Kudos
Message 1 of 3
(3,488 Views)
Solution
Accepted by topic author pblase

I do a lot of multi-threaded applicatons, so I have a couple thoughts for you.  Unfortunately, I have not tried to do much panel specific attribute changes from lower threads. 

 

I am very careful about how I handle thread "safeness", dealing with variables in an asynchronous manner as much as possible, to avoid blocking and erroneous use of variable values. 

 

But there definately a lot of things you just cannot do from daughter threads.  Things like issue popups and launch other threads just can't be done.  As long as you understand that the best place to do something is in the main thread, then a daughter thread can use PostDeferredCall(...), to do something in the main thread

 

In your daughter thread, you can insert this call:

PostDeferredCall (launchNewThread, 0);

 

And then that call executes this function in the main thread:
void CVICALLBACK launchNewThread(void *callbackData)

{
 CmtScheduleThreadPoolFunction (threadPoolHandle, NewThread, NULL, NULL);
}

 

Or you can insert panel attribute setting calls inside the above function, I suppose, to execute safely in the main thread.

 

Hoe this helps...

-- Gary


 

Message 2 of 3
(3,485 Views)

I'll try that, thanks.

Paul

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