06-23-2025 11:00 AM
I would like to service events generated by a .NET DLL (.net v4.6.2), I have a simple DLL to test put how this would interface to LabVIEW (2018).
Attached is my attempt so far. Any advice appreciated.
Solved! Go to Solution.
06-24-2025 04:45 AM
Please see a simplified version of the same attached. Above should read LabVIEW 2022.
I've included the source code of the DLL.
06-24-2025 05:16 AM
The way you setup your project, the Callback VI will be invoked everytime the .Net event is raised. So you need to have a way to cause your Demo002 VI to do something then. Possible solution:
1) not recommended: use a global or LV 2 style global to store something in whenever the Callback VI is executed.
2) Pass in a reference to a user interface element through the User Parameter of the Register Event Callback node and use that to generate inside the callback VI a value change event on that control that your user event handling loop can react on.
See Help->Find Examples... the example: Passing Data to a .Net Event Callback.vi.
3) You could also pass in a reference to a Queue or Notifier and communicate the events from the Callback VI through that back to your application.
06-24-2025 10:03 AM
the DLL was edited to remove the null value.
I can see in DebugView that an Event is generated when I press the "Raise Event" button.
The problem I have now, is that the code in the Callback VI does not execute in response to an event.
06-24-2025 10:53 AM
It executes, but you cannot see it, because the execution mode of the callback VI is set to preallocated clone.
Either put an invoke node to open its front panel or switch it to non-reentrant so you can open the instance from the project.
After the main VI runs, you may want to trigger a GC collect to unreserve the callback VI: https://forums.ni.com/t5/LabVIEW/net-event-callback-VIs-Why-do-they-never-leave-running-state/m-p/32...
06-25-2025 05:15 AM
Solved, solution attached.
This demonstrates LabVIEW handling interrupts from a .NET DLL.