Solved

C++ event callback converted to c# events

Posted on 2015-01-11
4
292 Views
Last Modified: 2015-01-11
Hi Experts,

I have a C++ callback interface (bunch of pure virtual functions in a class).  The c++ library is being instantiated in a c# class library now.

So naturally, I want to convert these "events" as c# events now.

My thinking is to create delegates in the wrapper library and convert them directly, firing them off to c#.

I know that on the C# side, if these events come from a different thread, I need to invokeLater.

Is there anything I could have done differently to make my life better here?  Looking for any great ideas at all...  :-)

Thanks,
Mike
0
Comment
Question by:thready
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40543190
Maybe this article could indeed help to make things easier: http://www.codeproject.com/Tips/393817/Pass-Csharp-delegate-as-Callback-to-Cplusplus ("Pass C# Delegate as Callback to C++") - if you just pass the delegates to the C++ callback interface to be invoked from there, it should be a piece of cake.
0
 
LVL 1

Author Comment

by:thready
ID: 40543220
I've got a bigger problem.  I'm trying to do this in my CLR class library.  I don't have the ability to add any C# classes to this implementation.  How can I fire off events in here?  Is there some other type of class that I can use in this context?  I don't even see how to do this at the moment...

Mike
0
 
LVL 1

Author Closing Comment

by:thready
ID: 40543226
I just clicked... I export these functions as in your link above.  Sorry about that!  :-)
Awesome.
0
 
LVL 1

Author Comment

by:thready
ID: 40543234
Actually, this is for the exported DLL type of interop... I'm not sure this works for the CLR class library method...
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question