I have an application where I need to send a inter-process message (a
data stream) that contains among other the address of a function (member
of a class).
For that, I need to serialize it, so I tried to cast it to an IntPtr,
but without success. And of course, on the receiever side, I need to
cast it back from IntPtr to the function pointer, in order to be able to
perform the callback function call, but this doesn't work either.
How could the needed casts be implemented ?
Here is a sample of my code :
On the sender side :
....
unsafe public delegate bool MY_FPTR(int param1, int param2);
class test {
....
unsafe public bool functie_test(int param1, int param2)
{
.....
}
some_function()
{
MY_FPTR myFPtr = new MY_FPTR(test_function);
-> this line does not compile !
IntPtr myIntFPtr = (IntPtr)myFPtr;
...
}
...
}
On the receiver side is similar :
someReceiverFunction()
{
IntPtr callbackIntPtr = ...;
-> this line does not compile either !
MY_FPTR myCallbackPtr = (MY_FPTR)callbackIntPtr;
...
}
Thanks in advance for your help.
*** Sent via Developersdex http://www.developersdex.com ***