|
-
February 23rd, 2010, 02:00 AM
#5
Re: How to awake main UI thread from another thread?
 Originally Posted by Arjay
By default, OnIdle( ) gets called when the UI thread is waiting for windows messages. So there isn't the concept of "waking up the ui thread to make it run OnIdle".
I suspect your overridden OnIdle( ) isn't getting called because your mController->run( ) method never returns.
At any rate, OnIdle( ) isn't really meant to perform work. It's only meant to do small amounts of work like updating UI states like menus and toolbar buttons.
What you need to do, as Alex F suggested, is to create a worker thread and do the work there.
OnIdle gets its returned value, from MSDN,
Eventually, OnIdle finishes processing all its idle tasks and returns 0. This tells the message loop to stop calling OnIdle until the next message is received from the message queue
That's the reason why I have to wake up main thread.
I can't return TRUE all the time, that made 100% CPU.
On the other side, running my own loop in another worker thread, I have to do much thread-safe work there which I'm thinking about the cost.
thx.
Last edited by LifeIsSuffering; February 23rd, 2010 at 02:12 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|