[Mono-devel-list] Embeding MONO and (p)threads

fran at cic-online.net fran at cic-online.net
Mon Aug 11 09:40:12 EDT 2003


Hi to everyone:

I just introduce myself to this mail-list and a question.

I am using MONO embeding in my application which creat several threads and i
need invoke CLR code from one of this threads.

I have a code like this:

---------------------------------------------------------------------------------------

int execute(IID id,void*packet,unsigned len)
{
 struct Service*s=(struct Service*)id;
 
 if(packet==NULL && len==0)
   {
    if(s->domain!=NULL)
      {

       // see only this part

       char*argv[] ={ NULL };
       int  retval;
       mono_thread_attach(s->domain);
       LPRINT0("I'm going to execute the CLR code ...");
       retval=mono_jit_exec(s->domain,s->assembly,0,argv);
       LPRINT1("Executed ;-) retval=%d",retval);
       return MT_PROACTIVE;
      }
   }
 else
 if(packet!=NULL && len>0)
   {
   }
 return MT_YIELD;
}

---------------------------------------------------------------------

This code is called from a thread (not main thread!!) and the code hang at line
where 'mono_jit_exec' is invoked.

[Of course there are other function which inizializate a mono domain and load an
assemby] ;-)

If 'execute' function are called from the main thread, it is executed :-D
If 'execute' function are called from other thread, it hang :-(

File 'gc/gc.h' is in each file together with 'pthread.h' and GC_PTHREADS_LINUX
are appended to the compliler FLAGS.

ok, the question are:

+ ¿am i forgetting anything?
+ ¿is it posible to execute CLR code inside other thread than the main thread?
+ ¿how?
+ ¿can anybody send me a sample of embed code, more complex than exists in 'cvs
mono'?

Thans in advance: Fran




More information about the Mono-devel-list mailing list