I don't know off hand of a simple example, but perhaps you'd find
mozilla/netwerk/base/src/nsAsyncStreamListener.cpp a useful example.
Take a look at the implementation of nsIAsyncStreamListener. The
interface is used to proxy nsIStreamListener methods from one thread to
another using event queues.
Essentially, you create a PLEvent object and associate it with a static
callback function. Then you post the event to the desired event queue,
and voila!
You can query a thread's event queue using nsIEventQueueService.
Darin
Rick Marvin wrote:
> Darin, thank you for your response. I'm hoping you can assist further with
> a new approach.
>
> Rather than having my child thread attempt to load the url, I would like to
> have my child thread send an EVENT to the main event loop and have the main
> loop route my event, utimately invoking a method I define. This would then
> cause the main thread to be the thread which is downloading the url.
>
> My questions come in about creating events and routing my event to invoke
> the desired method. After pushing my nose against the source code, I am
> still unsure about how to create an event which will be processed by the
> main event loop, and how to have the main event loop utimately invoke the
> desired method.
>
> Do you know of some sample code which maps a user defined event to a user
> defined method?
>
> Do you know of some sample code that creates and sends events which are
> handled by the main event loop?
>
> Any assistance you can provide would be appreciated.
>
> Rick Marvin
> (Neoplanet)
>
>