06-20-2012 12:53 PM
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.
Solved! Go to Solution.
06-20-2012 01:32 PM
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...