LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Registering and Handling .NET Events in LabVIEW

I'd like to be able to handle the events (documentation says it just tells us when we start/stop sampling and other things of that nature) in the application, so I think they do need to be exposed. To be honest though, I would be happy just being able to create an instance of the PropEngine with an empty/null/identity handler.

 

I've tried writing the wrapper myself, using all sort of combinations of private/public,static and not static, EventHandler and EventHandler<PropEventArgs>, etc, but to no avail. If you could show me what such a wrapper would look like, I'd really appreciate it.

0 Kudos
Message 11 of 12
(1,325 Views)

LabVIEW doesn't manage generics well so my advice is to create a basic delegate and event similar to below. In your wrapper class, call the event when the function is called

 

public delegate void PropEngineDelegate(object sender, PropEngineEventArgs args);
public event PropEngineDelegate Changed;

private void PropEngineEventHandlerFunc(object sender, PropEngineEventArgs eventArgs) { if (Changed != null)
{
Changed(sender, eventArgs);
} }

... In your constructor of the wrapper class
// Create the PropEngine _propEngine = new PropEngine(PropEngineEventHandlerFunc);

This way when the PropEngine API calls your attached callback funciton you fire a public event that the caller can access. In LabVIEW you can register for the event and supply a callback VI (or rather - let LabVIEW create it for you). 

0 Kudos
Message 12 of 12
(1,314 Views)