By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,979 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,979 IT Pros & Developers. It's quick & easy.

Firing events from within unmanaged code into a managed wrapper

P: n/a
Hi,
Sorry to be a pain in the neck managed vc++ newbie but Im having real
problems working through this problem. Its been a few years since ive
done any serious work in C++ and MFC and I cant seem to remember
anything relevant to my problem!

I have a managed wrapper class NetWriter that has a member of type
CNetWriter (the unmanaged class). What i want to do is for the
CNetWriter to signal to the NetWriter class in some manner (i was
thinking by invoking a method through a pointer? is this possible
somehow?) so that i can then place this in a managed event and fire it
off in C# or someother managed language.

Any ideas?

Thanks a lot
Kieran
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: 1
Hi Kieran

This is possible. You can have the unmanaged class take a function pointer, store it, and when the time is right, invoke that function to notify whoever is listening from managed land of the event. A function pointer in managed code is a delegate, so when you're calling into the unmanaged library, you need to send it a delegate.

I've done a full write up with code here, which may be helpful.
Apr 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.