[Mono-devel-list] Re: P/Invoke question -- debugging
Robert Jordan
robertj at gmx.net
Wed Feb 23 20:25:08 EST 2005
Hi Frank,
> Another question relating to P/Invoke on Mono. The problem occurs when a
> mono-callback function is called from a C-library (the delegate to the
> callback was previously passed to the library).
Is that delegate still alive? If you're using the delagate
like in this sample, then you're looking for trouble because
"d" is subject to be garbage collected.
void Method() {
SomeDelegate d = new SomeDelegate(Handler);
c_lib_register_callback(d);
}
Use a field to keep the delegate.
bye
Rob
More information about the Mono-devel-list
mailing list