LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Load and run a VI asynchronously from C#

Hello,
 
Does anybody know if it is possible to load a VI and run it asynchronously from within C#.
It needs to run asynchronously since the VI will run for a long time and it will also have to accept input / give output from / to the C# application.
 
The C# application is the master of this and many other similar VIs.
 
It should also be possible to let the VI show it's front panel to the user if the C# application instructs it to do so. (not at startup)
 
I tried using LabVIEW as an ActiveX server but was only able to call a vi synchronously with the vi.Call method.
The vi.Run method did not seem to work.
 
I would also prefer using the vi.Run method since I need to pass some parameters into the vi including the this pointer of the C# application. (to call some methods from the C# application from within my vi).
 
All help is greatly appreciated.
 
Thanks,
 
noxus
0 Kudos
Message 1 of 4
(3,198 Views)
What errors were you getting from the vi.Run method call? There's a
ResvForCall flag that's passed to the GetVIReference call (3rd
argument, iirc) that needs to be false for Run to work, but true if
you're using Call.

noxus wrote:
> Hello,
>  
> Does anybody know if it is possible to load a VI and run it asynchronously from within C#.
> It needs to run asynchronously since the VI will run for a long time and it will also have to accept input / give output from / to the C# application.
>  
> The C# application is the master of this and many other similar VIs.
>  
> It should also be possible to let the VI show it's front panel to the user if the C# application instructs it to do so. (not at startup)
>  
> I tried using LabVIEW as an ActiveX server but was only able to call a vi synchronously with the vi.Call method.
> The vi.Run method did not seem to work.
>  
> I would also prefer using the vi.Run method since I need to pass some parameters into the vi including the this pointer of the C# application. (to call some methods from the C# application from within my vi).
>  
> All help is greatly appreciated.
>  
> Thanks,
>  
> noxus

0 Kudos
Message 2 of 4
(3,189 Views)
As stated, the Run should work fine - please let us know more information about how it's failing and how your calling it.
 
Also, can you tell me more about how you plan to use the this pointer? You can pass it into LV as a 32-bit integer, but you can't convert it into a .NET refnum - those aren't actual .NET pointers, but special markers creating in LV - we keep the pointers internal. However, if you then want to pass it along to a .NET instance within the VI as an int32, and cast it back to the .NETreference, that would work.
 
Finally, if you want to built your LV code into a DLL and call that from C#, you can always call a wrapper VI, which in turn uses the VI Server to launch the real VI asynchronously. That gives you the most control over the behavior of the VI, and allows you to distribute your code w/ only the LV RTE as a dependency.
0 Kudos
Message 3 of 4
(3,181 Views)
Thanks for the suggestions.
I'll try them and see where I end up.
0 Kudos
Message 4 of 4
(3,175 Views)