cancel
Showing results for 
Search instead for 
Did you mean: 

Servicing events generated by a .NET DLL

SOLVED
bmann2000
Active Participant
Solved!

Servicing events generated by a .NET DLL

Message contains an attachment

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.

 

 

 

5 REPLIES 5
bmann2000
Active Participant

Re: Servicing events generated by a .NET DLL

Message contains an attachment

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

I've included the source code of the DLL.

rolfk
Knight of NI

Re: Servicing events generated by a .NET DLL

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
bmann2000
Active Participant

Re: Servicing events generated by a .NET DLL

Message contains an image

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

cordm
Active Participant

Re: Servicing events generated by a .NET DLL

Message contains a hyperlink

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

 

bmann2000
Active Participant
Solution

Re: Servicing events generated by a .NET DLL

Message contains an attachment

Solved, solution attached.

 

This demonstrates LabVIEW handling interrupts from a .NET DLL.