[Mono-devel-list] Calling C# delegate from native code on a different thread.
Zoltan Varga
vargaz at gmail.com
Tue Jul 20 14:11:01 EDT 2004
Hi,
The function is called mono_thread_attach (). For more info on the
mono embedding
interfaces:
http://www.mono-project.com/using/embedded-api.html
Zoltan
----- Original Message -----
From: Daniel L. Christensen <dachristensen at gw.novell.com>
Date: Wed, 14 Jul 2004 12:03:16 -0600
Subject: [Mono-devel-list] Calling C# delegate from native code on a
different thread.
To: mono-devel-list at lists.ximian.com
I'm trying to wrap a native C++ API with C#. I've run into a
spot where the C# object needs to register for an event that occurs on
the native C++ object. So I pass down a delegate which gets converted
to a function pointer on the native side, wrap the funciton pointers
with an event handler object and register the event handler object
with the native C++ object. Certain actions performed by the C++
object happen asynchronously (i.e. on another thread that mono doesn't
know about). When the action completes (or is in progress) it
generates a native event. The native object calls back on the event
handler which in turn tries to call back up into the C# code using the
function pointer that was created from the delegate. When this happens
I get the following error:
** ERROR **: file mini.c: line 6508 (mono_get_lmf_addr): should
not be reached
aborting...
I imagine that the problem is that I am trying to communicate to
the mono vm from a thread that is not attached to it. When attempting
a similar operation in Java/JNI, you are required to attach the JVM to
the native thread before trying to call up into java. Does mono have a
similar convention? How is this accomplished? Or, is there a better
way to accomplish this using mono?
Thanks,
Dan Christensen
More information about the Mono-devel-list
mailing list