Example Code

Print VI causing Front Panel to freeze and different LabVIEW Threads

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

 

Functional Description

The purpose of this VI is to show that even while the Print.Panel To Printer VI is executing, other loops are not stopped. They may be delayed, but execution does occur. Using the Print.Panel To Printer will cause the User Interface thread to hang causing the user to think that the VI has stopped executing tasks in the background, but that is not the case.

 

To show that other loops continue their execution while the front panel has frozen during the printing process the millisecond timer value is recorded and the number of loop iterations is calculated of the non printing loop.

 

See the VI documentation and the notes in the block diagram for more information.

 

Caveats and Additional Notes
See KnowledgeBase DIRECT-3S8R8M: How Many Threads Does LabVIEW Allocate? for more information

Front Panel:
thread test fp.jpg

Block Diagram:
thread test bd.jpg

 

 

 

 

 

 

 

Joshua B.
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
wldgoose
Member
Member
on

The workaround that I do, is I export what I want to print to file, and use another application to programmatically print it.  For example, if I want to print a front panel, I export it (to actually an RTF file in my case in appdata/local/temp), and then have MS Word actually print it minimized.  This way my front panel never hangs, and any OS calls that cause any freezes are Word's problem and not my LabVIEW's application.

 

Love the example code.