On Mon, May 25, 2009 at 2:58 PM, Book'em Dano <[email protected]> wrote:

>
> MessageLoop::PostTask() runs a method asynchronously within a
> destination thread. The problem I have is that I'd like to execute
> this code (on the destination thread) synchronously.


We use WaitableEvent when we need to do this kind of thing.



>
>
> More details: I'm using a NotificationService on a worker thread
> (which uses TLS), so I need to proxy the call to add/remove observers
> from the main thread over to the worker thread. To do this, I'm
> calling PostTask to invoke the add/remove observer code on the work
> thread. I want/need to block the main thread though until the add/
> remove observer code has actually been processed by the worker
> thread.
>
> What is the recommended way to do this?


It is typically very bad to make the UI thread block on any child
thread.  So, while you could post a task with a WaitableEvent that
gets signaled from your Task's Run method, that really is something you
should avoid.

Without more information about what you are trying to do, it is hard to give
you good advice on an alternative solution.

-Darin

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected] 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to