.NET objects will often throw events to alert the instantiating object that certain events have occurred. For instance, a Timer class will throw an “Elapsed” event when the interval expires. UI Controls have events like MouseClick, KeyPress, etc.
To handle these events in LabVIEW, you can register a VI as a Callback VI that will get called automatically when the event is fired or thrown.
Once you have a reference to a .NET object, you can register for events of the object by using a Register Event Callback node (Functions Palette » Connectivity » .NET » Register Event Callback).
The Register Event Callback Node will automatically populate with a list of available events as soon as you wire in an object reference to the node.
Callback VIs have to match a certain template for their inputs and outputs. The easiest way to create a callback VI is to right click on the VI Ref input of the Register Event Callback node and select Create Callback VI.
The following code sets up a System.Timers.Timer and callback VI to handle the Elapsed event. The callback VI displays a message popup.
The following examples install with LabVIEW:
Calculator VI: labview\examples\comm\dotnet\Calculator.llb
SimpleTaskMonitor VI: labview\examples\comm\dotnet\SimpleTaskMonitor.llb