LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Servicing events generated by a .NET DLL

Solved!
Go to solution

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.

 

 

 

0 Kudos
Message 1 of 6
(177 Views)

Please see a simplified version of the same attached.  Above should read LabVIEW 2022.

I've included the source code of the DLL.

0 Kudos
Message 2 of 6
(131 Views)

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.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 6
(121 Views)

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.

DebugView_GotAnEvent.JPG

0 Kudos
Message 4 of 6
(95 Views)

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...

 

0 Kudos
Message 5 of 6
(87 Views)
Solution
Accepted by bmann2000

Solved, solution attached.

 

This demonstrates LabVIEW handling interrupts from a .NET DLL.

0 Kudos
Message 6 of 6
(50 Views)