G
Guest
I am trying to use delegates for the first time and I am probably missing
something. I have a legacy DLL and I have used DllImport to get to the
functions that it contains...the normal function calls work fine, but I can't
get callbacks to work. The delegate declaration etc is below.
public delegate void callbackEvent();
callbackEvent Event = delegate()
{
MessageBox.Show("Callback Event Received");
}
The function in the DLL to register the callback is
myAPIregister(Event);
So I am expecting that myAPIregister(Event) will provide a pointer to the
Event delegate. When the callback event occurs it should simply display the
MessageBox with the text. The parameter in myAPIregister(parameter) is
expecting a pointer to the callback handler.
I have done a lot of reading about delegates over the past few days to get
this far but I appear to be missing something. The Compiler complains that
the argument is invalid.
Thanks for any help and guidance.
something. I have a legacy DLL and I have used DllImport to get to the
functions that it contains...the normal function calls work fine, but I can't
get callbacks to work. The delegate declaration etc is below.
public delegate void callbackEvent();
callbackEvent Event = delegate()
{
MessageBox.Show("Callback Event Received");
}
The function in the DLL to register the callback is
myAPIregister(Event);
So I am expecting that myAPIregister(Event) will provide a pointer to the
Event delegate. When the callback event occurs it should simply display the
MessageBox with the text. The parameter in myAPIregister(parameter) is
expecting a pointer to the callback handler.
I have done a lot of reading about delegates over the past few days to get
this far but I appear to be missing something. The Compiler complains that
the argument is invalid.
Thanks for any help and guidance.