Maintaining Parallel Performance When Using DLLs Generated From LabVIEW

Updated Sep 29, 2023

Reported In

Other

  • C/C++
  • C#
  • .NET
  • Python

Issue Details

  • I have a LabVIEW program that can run processes in parallel. When I try to export my program as an .NET Interop Assembly and run it from a C# process it takes much longer to finish calculations than in LabVIEW.
  • I have a LabVIEW program that runs a producer and consumer in parallel but when I export it to a DLL and call it from a C program it runs sequentially.

Solution

The issue arises due to the inherent differences in how LabVIEW and text-based programming languages handle multithreading. LabVIEW is designed to automatically manage parallelism, allowing for efficient execution of multiple tasks simultaneously. However, when a DLL is created from LabVIEW code and used in a text-based program, this automatic parallelism is not automatically preserved.

The reason for this is that text-based does not inherently support the same level of automatic parallelism as LabVIEW. When you call a DLL from a text-based programming language, it runs in the context of the calling thread.

To maintain the parallel performance of your LabVIEW code when creating a DLL and using it in any other programming language, follow these steps:
  1. Open the top-level VI Properties Ctrl + L
  2. Select the Execution Category
  3. Set the Prefered Execution System to standard.
Preferred Execution System