By default, when you start multiple asynchronous calls to the same VI, LabVIEW serializes the calls, forcing them to run one at a time and leading to a longer cumulative execution time. Use the following procedure to execute the calls in parallel, preventing any one call from delaying the execution of another call.
Use the following block diagram objects to dynamically start an asynchronous call to a reentrant VI and then collect the outputs of the VI at a later time:
|Strictly Typed VI Reference||Open VI Reference||Start Asynchronous Call||Wait On Asynchronous Call||Close Reference|
Create the following block diagram to start multiple asynchronous calls to a reentrant VI and then collect the results.
The following list describes important details about the previous diagram.
|Configure the VI specified by vi path for reentrant execution by selecting either Shared clone reentrant execution or Preallocated clone reentrant execution on the Execution page of the VI Properties dialog box.|
|Include the 0x40 flag as part of the options input to the Open VI Reference function. LabVIEW requires this option flag to start simultaneous calls with the reentrant VI reference. Otherwise, LabVIEW serializes the calls.
|You can combine option flags to specify multiple characteristics of the target VI reference. In this use case, combining the 0x100 option flag with the 0x40 option flag configures LabVIEW to call-and-collect simultaneous calls to the VI.|
|Use the same number of Wait On Asynchronous Call nodes as the number of Start Asynchronous Call nodes for a specific reference.|
|When you include the 0x40 option flag, the Start Asynchronous Call node calls a clone of the target VI rather than the target VI itself. Refer to the Caveats and Recommendations for the ramifications of calling a clone VI.|
|If you start multiple calls to the same VI reference, you cannot directly identify which instance of the VI returns its outputs to a specific Wait On Asynchronous Call function. Assign an identifier to a VI call if you need to know which instance of the VI returned.|
|Close each open VI reference with the Close Reference function after you collect the results.|
|Note If you want to ignore the results of the asynchronous calls, omit the Wait On Asynchronous Call node and include the 0x80 option flag instead of the 0x100 option flag.|
VI Server properties and methods cannot modify parallel instances of an asynchronous VI call. If you call a VI Server property or method on a 0x40 VI reference, the property or method cannot modify the VI clone that the Start Asynchronous Call node actually calls. Instead, the property or method affects the original target VI. To apply VI Server properties or methods to the VI clone that the Start Asynchronous Call node actually calls, call the property or method within the target VI itself.
Refer to the Asynchronous Call and Collect (Using Option 0x40) VI in the labview\examples\Application Control\VI Server\Asynchronous Call By Reference directory for an example of asynchronously calling parallel instances of a VI to reduce execution time.
Refer to the Benchmarking Asynchronous Calls VI in the labview\examples\Application Control\VI Server\Asynchronous Call By Reference directory for a comparison of several synchronous and asynchronous approaches to solving the same task.