Asynchronously Calling a VI without Collecting the Results
When you open a reference for a VI that you want to call asynchronously, you must decide whether you want to collect the results of the VI later. This topic describes how to start an asynchronous call-and-forget VI call without tracking when or what values the VI returns. Other programming languages describe this usage model as fork-and-forget. Alternatively, you can call a VI and collect its results later.
What to Use
Use the following block diagram objects to asynchronously call a VI without collecting its results:
What to Do
Create the following block diagram to dynamically start an asynchronous call to a VI without collecting the results.
The following list describes important details about the previous diagram.
| Include the 0x80 flag as part of the options input to the Open VI Reference function. This option flag causes LabVIEW to create a call-and-forget VI reference to be called asynchronously without returning its results.
|
Note The LabVIEW Help displays each of the option flags for the Open VI Reference function in hexadecimal representation. Therefore, always change the display format of the Numeric Constant input to hexadecimal to ensure that you are passing the correct value. |
|
| The Start Asynchronous Call node does not allow you to collect outputs immediately. If you want to access the outputs of a VI you called asynchronously, you must explicitly prepare the VI reference to return its outputs. |
| After the Start Asynchronous Call node calls the referenced VI, the rest of the calling block diagram continues executing without waiting for the referenced VI to complete. |
| You can close the VI reference with the Close Reference function as soon as you are finished using it to start asynchronous calls to the referenced VI. When you close a call-and-forget VI reference, LabVIEW does not abort instances of the VI that are already running. However, once you close the reference, it becomes invalid so that you can no longer use VI Server properties and methods on the reference. This behavior differs from closing call-and-collect VI references.
|
Caveats and Recommendations
- Do not call VIs that never terminate. After you start a call with a call-and-forget VI reference, LabVIEW does not abort the target VI when the calling VI finishes executing. Instead, the target VI executes to completion regardless of whether the calling VI is still running. Therefore, if the target VI contains an infinite loop or otherwise cannot finish executing, it remains in memory until you close LabVIEW and may negatively impact performance.
- If you call the Abort method on a call-and-forget VI reference, LabVIEW aborts all currently running instances of the VI.
Examples
Refer to the Asynchronous Call and Forget VI in the labview\examples\Application Control\VI Server\Asynchronous Call By Reference directory for an example of asynchronously calling a VI without collecting its results.
Open example Find related examples