Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Callback VIs

LabVIEW 2011 Help

Edition Date: June 2011

Part Number: 371361H-01

»View Product Info
Download Help (Windows Only)

A callback VI contains the code you write to handle an ActiveX or .NET event you specify. You must create a callback VI to handle events from ActiveX controls or .NET objects when the controls or objects generate the registered events. The callback VI runs when the event occurs. When you create a callback VI, LabVIEW creates a reentrant VI that you can open and edit to handle an event. A callback VI contains the following elements:

  • Event Common Data contains the following elements:
    • Event Source is a numeric control that specifies the source of the event, such as LabVIEW, ActiveX, or .NET. A value of 1 indicates an ActiveX event. A value of 2 indicates a .NET event.
    • Event Type specifies which event occurred. This is an enumerated type for user interface events and a 32-bit unsigned integer type for ActiveX, .NET, and other event sources. For ActiveX events, the event type represents the method code, or ID, for the event registered. You can ignore this element for .NET.
    • Time Stamp is the time stamp in milliseconds that specifies when the event was generated.
  • Control Ref is a reference to the ActiveX or automation refnum or .NET object on which the event occurred.
  • Event Data is a cluster of the parameters specific to the event the callback VI handles. LabVIEW determines the appropriate Event Data when you select an event from the Register Event Callback function. If an event does not have any data associated with it, LabVIEW does not create this control in the callback VI.
  • Event Data Out is a cluster of the modifiable parameters specific to the event the callback VI handles. This element is available only if the ActiveX or .NET event has output parameters.
  • (Optional) user parameter is data that you want to pass to the callback VI when the ActiveX or .NET object generates the event.
Note  You can use an existing VI as a callback VI as long as the connector pane of the VI you intend to use matches the connector pane of the event data. The callback VI must be reentrant, and the reference to the callback VI must be strictly typed.

To allow callback VIs to execute without interruption, LabVIEW delays the processing of operating system messages until any callback VIs stop execution or until you load a modal window. When LabVIEW delays the processing of operating system messages, you cannot interact with any LabVIEW front panels. A modal window is a type of window that remains active or remains on top of all other LabVIEW windows until you close the window or open another modal window. You cannot interact with other windows while a modal window is open. Most dialog boxes in LabVIEW are modal windows.

You cannot open a non-modal window from a LabVIEW callback VI nor a DLL while any other process is running. Refer to Calling Non-Modal Windows Programmatically for more information about calling a non-modal window from a callback VI or DLL.

Note  ActiveX objects call ActiveX callback VIs synchronously. This means that the object may not be able to run other code during the execution of the callback and may cause deadlocks. You should carefully consider the interactions between the callback diagram and other code. For example, calling a non-reentrant subroutine inside an ActiveX callback VI could hang if you call the callback while the subroutine is already executing.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit