[Mono-list] pthreads in mono

Jestin Stoffel jestin.stoffel at gmail.com
Thu Mar 27 09:38:16 EDT 2008


On Thu, 2008-03-27 at 07:33 -0400, Chris Howie wrote:
> On Thu, Mar 27, 2008 at 7:18 AM, Andreas Färber <andreas.faerber at web.de> wrote:
> >  You sure about that? Mono does use pthreads in some way, keeping it
> >  from running on BeOS.
> >
> >  Is getting a pointer to the current thread in native land or using p/
> >  invoke not an option?
> >
> >  Andreas
> 
> The whole point of those specific native functions is to run an
> asynchronous loop on the specified thread, so getting a pointer to the
> current pthread would not be useful.  However, you may be able to get
> a pointer to some other Thread object's pthread, but I would not be
> too sure that this can be done from Mono directly.
> 
> You could use: [DllImport("pthread")] private static extern pthread_t
> pthread_self();
> 
> However, you'd have to declare pthread_t somewhere, and this call
> would have to be executed from the other thread -- meaning you'd have
> to pass the return value over to the main thread and ... ugh.  A
> WaitHandle would undoubtedly be needed, and for what?
> 
> Writing a ThreadStart that infinitely loops over a call to gps_poll
> sounds like a lot less work, no?
> 


All things considered, libgps is really just a socket reader and parser,
and reimplementing it's functionality might just be the easiest solution
of all.  I'm a good halfway done, and hope to have something up and
running later tonight (when I get home from work).  Thanks for all the
input.

--Jestin



More information about the Mono-list mailing list