From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

How Can I Detect When Certain Events Occur?

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

    Operating System

  • Windows

Code and Documents

Attachment

Description

This article introduces you to a Windows function that is similar to the poll function in Linux. You can use this function with LabVIEW to react when certain events occur in the operating system occur, such as a process reaching a specified state, a system event, or a mutex unlocking.

How to Use

The equivalent function that can be used with LabVIEW is the Windows function WaitForSingleObject. This function waits until the object specified by the passed handle is in the signaled state, or until the specified time-out interval has elapsed.

The function WaitForSingleObject is contained in Windows' kernel32.dll. The attached VI demonstrates how to use it.

Additional Information

Use the similar functions WaitForSingleObjects, WaitForSingleObjectEx, and WaitForSingleObjectsEx to wait for multiple objects, and to enter an alertable wait state, respectively.

Related Links

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

Contributors