- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All Topicscurrently i'm working on an app which simply said exists an an c-dll and a gui (currently in mfc)
in the gui app there is a callback function which is passed to an exported function in the dll, which is called for enumerating something to fill the gui.
but now i would rather use c# to implement the gui, because its faster to implement, easier to service, i don't like mfc ;-), ...
porting the c-dll to c# isn't possible because it would waste too much time.
know i know several different methods to do this.. but it would interest me how u guy's would implement such a communication.
regards
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: bgungorPosted on 2003-01-03 at 11:10:51ID: 7664093
Considering that you are passing a function pointer (your callback) to the C DLL, it may be difficult to create a function in C# with the exact signature you have for your current callback.
Despite this potential problem, I would recommend you create a delegate in C# with the same signature as your MFC callback, implement it in your C# GUI, and pass a reference to that implementation method. Remember that the method should probably be static, so you don't have to worry about an implicit "this". You will have to see, through testing, whether there will be compatibility issues.
If you have control over the C-DLL, you wouldn't have to rewrite it, but only perhaps change the signature of the expected callback.
Best practices wise, if the C DLL is really C++, and you can import the managed core, you could wrap your DLL functions in a managed C++ class, giving you much more flexibility.
Hope this helps,
Bg