LabWindows/CVI

Content Type
Programming Language
Current manual

Running Code in Secondary Threads

Running Code in Secondary Threads

The thread in a single-threaded program is referred to as the main thread. The OS creates the main thread when the user tells the OS to begin executing a particular program. In a multithreaded program, the program itself tells the OS to create threads in addition to the main thread. These threads are referred to as secondary threads. A major difference between the main thread and secondary threads is where each type of thread begins execution. The OS begins execution of the main thread in the main or WinMain function. You specify the function in which each secondary thread begins executing.

In a typical LabWindows/CVI multithreaded program, you use the main thread to create, display, and run the user interface. You then use secondary threads to perform other time-critical operations such as data acquisition. LabWindows/CVI provides two high-level mechanisms for running code in secondary threads: thread pools and asynchronous timers. A thread pool is appropriate for tasks that you need to perform a discrete number of times or tasks that you need to perform in a loop. An asynchronous timer is appropriate for tasks that you need to perform at regular intervals.

Was this information helpful?

Help us improve your future ni.com experience.

Did you find the documentation you were looking for?

Submit