[Mono-dev] when to call mono_thread_attach

Robert Jordan robertj at gmx.net
Wed Apr 13 16:26:12 EDT 2011


On 13.04.2011 19:19, Ng, Victor wrote:
> Hi all,
>
> I'm trying to embed a Mono process inside of CPython but I'm having
> some trouble with threads.
>
> When am I supposed to call mono_thread_attach?

 From within threads not created by Mono...

> Right now, I'm invoking it immediately after mono_jit_init and
> immediately before I instantiate and initialize an object and prior
> to finding and invoking a method on an object.

... but you don't need to call it from the thread that
invoked mono_jit_init.

> Also, how do I know what objects I have to call mono_free on?  I
> can't seem to find a good reference on that topic.

This is usually well-documented.

> Are there also objects where I have to 'pin' them into memory for the
> Mono GC?

Of course. You have to pin *all* MonoObjects that you're going to
store into places other than the stack.

Robert



More information about the Mono-devel-list mailing list