I don't get the point, nothing in this sample is unmanaged code, everything
gets compiled to IL.
What you are doing can just be done like this:
class umgt
{
public:
void MyTreatment(mgt ^obj)
{
MyParameter ^param = gcnew MyParameter;
param->m_value = 123;
obj->MyCallback(param);
}
};
So I don't think this illustrates how to callback from unmanaged to managed.
Willy.
"Remi THOMAS [MVP]" <is*****@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
| Hi,
|
| I did spend quite a long time finding how to call managed code from
| unmanaged C++ class.
| Here is the my final code:
|
http://xtware.com/mcallback/mcallback.htm
|
| Is it the best way to do it?
| Does
| mgt^ callback = (mgt^)GCHandle::FromIntPtr(IntPtr(m_callback)).Tar get;
| take long time to execute?
|
| Can we do it a better way?
|
| Remi
|
| ps: I'll publish optimal solution in codeproject, there is so many people
| having this question!
|