Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to recieve LabVIEW events from C#

Hi, I have C# .NET application that interacts with LabVIEW application. For the correct interaction I need to subscribe to the LabVIEW events. To solve that issue I have made small PseudoCallback dll (code is attached) in C# using delegate that should be inserted to LabVIEW to wrap this functionality. As known C# uses delegates used to subscribe to the events (pointer to function in C++). But this delegate seems doesn't work, and now I am a bit stocked.  Is it possible to do such thing in LabVIEW? How to do that?Any help will be appreciatedThanks in advanceSasha 

 

unsafe public class Class1

{

public delegate void PseudoCallback_delegate(int A);

 public event PseudoCallback_delegate Event1;

 

 public void PseudoCallback(int Event_Data)

{

    Event1(Event_Data);

}

}

0 Kudos
Message 1 of 13
(7,696 Views)

Hello Sashok,

 

I am a little bit unclear about how these two applications will be interacting with each other.  Are you planning on calling a C# dll from within LabVIEW?  Also how do you plan on subscribing to particular LabVIEW events?  Let me know and I will try to find more information for you.

0 Kudos
Message 2 of 13
(7,671 Views)

Hi, Burt!

My main acting application is C# window application, from that C# application I should call some data grabber written in LabVIEW. This data grabber has events inside (like: data is ready to be read, data is empty and so on). And my goal is to respond to those events happening in LabVIEW data grabber dll. The response should be in my C# main application. So, somehow I should see those events inside C# application. How can I do that? The one possible solution is to work with polling mechanism. But I don’t like that way, I want it to be pure event driven application.

Regards

Sashok

0 Kudos
Message 3 of 13
(7,665 Views)

Hello Sashok,  I am not sure whether or not there is a way to do this.  I am currently looking into it.  I am curious why you have decided to set-up your application this way.  If you have created a .dll from VIs you have made, could you do the event handling in LabVIEW and return any final values.  Also what exactly do you plan on doing with the event once you receive it in C#?  Unfortunately I am still going to need some more information before I can make any real helpful suggestions.  In the meantime, I will continue to look for a way to see LabVIEW events in C#.

0 Kudos
Message 4 of 13
(7,645 Views)

Hi, Burt! Thanks for your response on LabVIEW C# issue. Let’s assume that LabVIEW data grabber dll writes series of sets of data on disk (data could be voice or video), each time new series. As I receive event, for example that series was successfully written to disk I will manipulate with data written.

The possibility to work with LabVIEW event handling exists, same as pure C# code, but the problem is that different parts of my application were developed by different people.

 

Regards

 

Sasha

0 Kudos
Message 5 of 13
(7,608 Views)
Hello Sashok,  would it be possible for you to post your LabVIEW source code and dll so that I can do some experimentation with the code you are using?
0 Kudos
Message 6 of 13
(7,569 Views)

Hi, I am sorry, but I can’t send you my code, since it’s the proprietorship of the company I am working in. I think that you can emulate such dlls very easy. You should have very simle LabVIEW dll that only fires events, and C# .NET main program that should run this dll and response to the events. That’s it.

 

Regards

 

Sashok

0 Kudos
Message 7 of 13
(7,557 Views)

Hello Sashok,

 

I am working on reproducing this but I have one more question for you.  What type of events are being generated by this dll?  Do you happen to know if they are an ActiveX event, a DAQ Hardware event, or a User Generated event?  The way the events get handled are different depending on which type of event it is.  Thanks.

0 Kudos
Message 8 of 13
(7,532 Views)
Hi!!


We are working in a project which involves a lot of interaction between applications, written in C and LabView.

We have developed a DLL which is called by LabView. It works fine. We call a DLL function and it responses. It was our first step to get them communicated.

On the other hand, the DLL we are using is multithreaded. Some events happen even when a C function is not being called. If that external event occurs, a thread is noticed (the threads watch some external parameters). After that, the thread should tell to LabView that something has happend (and some simple datum, for example an int value). We are using a polling architecture by the moment, but we think there should be a more accurate solution.

Regards,

Mauricio


0 Kudos
Message 9 of 13
(6,831 Views)

Hi  Mauricio J,

I am not too familiar with C but what type of solution were you looking for. Something that is more efficient?

 

Flash

National Instruments
Applications Engineer
0 Kudos
Message 10 of 13
(6,766 Views)