LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

seperating code from ui - how to send signals to GUI when in RunUserInterface() mode

Hi,
I am developing an application while applying a good software engineering technique that aims to seperate the GUI from the application code.  After gui is running "RunUserInterface()", I do things in my applicatoin code, such as reading information from a .ini file.  To keep the GUI and application code as much "Consumer" and "Producer" respectively as possible, I'd like to notify the GUI, for example, when while reading the .ini file a problem is encountered, and then have the GUI then request data from the application to display.  My problem is:  How do I notify/signal the GUI once it is in 'RunUserInterface() mode?  From the documentation, it looks like only the GUI is only listening to events that are happening on the GUI (such as mouse-click).
Thanks,
Owais

0 Kudos
Message 1 of 2
(3,116 Views)
Owais,

I would call the User Interface library function PostDeferredCall() from your "Producer" thread. Here is the prototype:

int PostDeferredCall (DeferredCallbackPtr Deferred_Function, void *Callback_Data);

To pass information in the other direction, use PostDeferredCallToThread().
Note: Callback_Data is either NULL or a pointer to data that you define.

There are other ways to provide communication between the threads of your app, including Thread Safe Queues.

Your main thread will respond provided you call RunUserInterface() or ProcessSystemEvents().

Here is a useful reference on multithreading.

Regards,
Colin.

Message 2 of 2
(3,106 Views)