Jump to content

Recommended Posts

Hi, I want to implement the SSL Begin Read method in LabVIEW with the System DLL using the .net construtor nodes.I am successful in doing so for the synchronous Read method. But when I am trying to modify my code with the Asynchronous methods, it asks me to wire reference for a Asynchronous Callback node. I haven't worked with Event Callbacks in .net before , so I dont have much clue about the dataflow and other things.Can anyone please help me regarding creating callbacks in this particular case.Regards,Runjhun.

Link to comment

I can't give a solution for your specific problem, but .net callbacks are easy to understand:

- Place the Register Event Callback node from the .NET palette into your VI

- Wire the .NET class reference to the Event input (the third connector from top-left! not the first!) -> Now you can select an event from the drop-down box where all available Events are listed

- Once you've selected your event, rightclick the VI Ref terminal and select Create Callback VI

- Do whatever you want in the callback VI (like trigger a LabVIEW event)


Now whenever the event is fired, your callback VI is called... Try it with a message window ;)


Hint: Wire some data to the User Parameter input of the Register Event Callback node and re-create the callback VI. This is how you could send a LabVIEW event refnum (or any type of data) into a callback VI.


Hope that helps. Upload your VI if you need help for your specific solution.



Ehem, I hate to post links but:





Edited by LogMAN
  • Like 1
Link to comment



I have gone through the basic working of Event Callbacks but I have found examples that are related to UI events.

In my case, I am reading some data from TCP socket and I want to generate event from that using the callback, so that it becomes an Asynchronous operation.


The code that I am trying to convert to LabVIEW is the SSL Stream Begin Read method.



I have posted my VI as well but as of now its broken because there's nothing wired to the callback function.

Async Read.vi

Link to comment

Interesting task, some VIs are missing though (from your user.lib), but I get the critical part now.


As far as I know there is no way to pass a delegate from LabVIEW to a function (as there are no raw delegates in LabVIEW). Also, even though the parameter is called 'asyncCallback', it is not an event callback, but just a parameter you could pass (any?) delegate to. The delegate could be registered as an event by the caller. I searched the internet and found a similar topic:



The first answer states:


LabVIEW 8 introduced support for .NET events but we don't have support for raw delegates (the AsyncCallback parameter)...


I think this is still true. The only option I see for this is to write your own wrapper that internally handles the delegate and provides an event for LabVIEW to register to. Of course you would also have to wrap the method you want to call in order to provide a method without the delegate parameter.


I'm quite sure I've seen a similar topic here before... I guess...

  • Like 1
Link to comment

Yes. So I am trying to build my own callback but the problem is the callback function has an argument of type 'IAsyncResult'.

But when I am selecting the consturtor node for this class, I get the message as 'There are no public constructors for this class'.


What to do in this case ?

Link to comment
  • 1 month later...

ned, can you please elaborate on this. May be with an example.

I understand Asynchronous calls are difficult implementation in .net as well as LabVIEW but in my project I am not seeing any way out here for that.

I have to implement few methods as asynchronous only.


Can you please help here ?


Runjhun :)

Link to comment
  • 4 weeks later...

I found the solution to my problem. I had to write a .net application that was triggering an event whenever bytes were received on a socket.

And as LogMan specified earlier, I used Regiter for .net Event node and passed the socket reference to it.

With that whatever events were related to that class, they were populating in that list. So, I created a Callback VI, that would generate a Value Signaling event to an inetger array that would give me the bytes read from the socket.


Appreciate everyone for their suggestions.




Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.