Printing takes time, and it wants to run in the UI thread.  Perhaps one
of the Win-API wireheads out here has a way to invoke background
printing, but I found a way to do it in pure G.

I create a separate application; let's call it the "YYY_Project Print
Service.exe".  The application's job is just to sit there, but its INI
file configured the VI Server to listen on a port other then the default
3363.  See the app note -> 

"How Can I Communicate Between the LabVIEW Run-Time Environment and the
Development Environment on the Same Computer?"
http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/c32e9c
d39e234dfb86256de1007840b2?OpenDocument

Make sure to include a Dynamic VI when you build the app.  That VI will
be the one whose has the panel you would like to print.  Open a VI
Server Application reference directed at the port you selected for the
Services app, then open a VI reference to the printing VI, invoke the
Set Control method to pass your data to the specific controls, and then
invoke the Run VI method without waiting for completion.  All the VI
Server stuff is non-blocking, meaning that your code will not have that
characteristic 30 second pause.  Windows will multi-task for you and
allow the Services app to print the document while your UI remains
responsive.

The caveats are that you have to make sure your Services app is running
before trying to open the reference to it.  Only after it is launched,
will it listen on that port.  You should also provide a method for
shutting it down.  It won't be a particularly large app, but you should
still practice good housekeeping and shut it down.  The top-level VI in
the app could consist of nothing more than a while loop with a Wait
function inside and a Boolean wired to the loop condition.  You can use
VI server to set that Boolean to stop the loop.

Remember that built apps act like folders when you want to open a
reference to a specific VI.  Just wire the path to your printing VI such
as "C:\My App\YYY_Project Print Service.exe\Print Me.VI".

Now go upgrade to LabVIEW 7.1 and XP Pro.  1999 called; they want their
software back.  :)

Daniel L. Press
PrimeTest Corp.
www.primetest.com





Reply via email to