LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I customize the RunUserInterface functionality?

My application (LabWindows/CVI) was originally developed to operate with controls on user panels.  I now am modifying it to continue to operate the same, along with operating from a host interface by responding to commands.  My approach for this is to start a thread that simply scans the interface for incoming commands, then activate the appropriate control's callback in the main program.  This works great for simple 'do-and-return-rightaway' functions, but there are a couple that do not return from the Callback for some time, and during this time the code in the interface handler hangs until the Callback returns.
I need to be able to have the interface handler initiate a trigger to the main program, without actually calling the Callback function.  I tried to use the QueueUserEvent(...) function, hoping that RunUserInterface(...) would respond as if the panel control had been activated, but it didn't.  My next thought is to replace my RunUserInterface(...) call with a loop that does the same thing, and that includes a GetUserEvent(...) call that I could then call the Callback function with the results of.  If this doesn't work, my last recourse would be to rewrite most of the main program to operate completely different; something that I neither want to do nor believe is necessary.
What code does the RunUserInterface(...) method contain?
0 Kudos
Message 1 of 3
(3,339 Views)
If I were in your position, I'd look at using the PostDeferredCall() function from your host interface thread, to signal the user interface thread to call a pre-defined function.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 3
(3,334 Views)
To keep the user interface from blocking your host interface you need to run the host interface from a separate thread.  This way the host interface response is not dependant on the main thread to complete a task before it can respond to commands over the host interface.    As suggested above you can use PostDeferredCall() to place callback events in the main thread that is executing runuserinterface().  You could have the main thread poll a TheadSafeQueue of commands to determine what needs to be executed, or you can post the events to the main thread directly from the host thread.  There are a lot of ways to approach this task and best method will depend on your specific application requirements.   Look at the CVI examples for multithreading for ideas on how to set up a separate host interface thread and how to pass information between threads. 

Message Edited by mvr on 08-16-2007 07:19 AM

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