views:

110

answers:

2

How do you handle update refresh rate from your worker function to your UI ?

Sending everything to the UI or maybe using a timer (from which side ? worker or UI ?)

+1  A: 

In Windows apps, you generally want to use a Timer object in your GUI thread to poll for worker status -- it's easier, unless you have a really good reason to do something else...

You can't just make a function call to a UI routine from a worker thread in Windows. Undefined behavior will result, so watch out!

Dave Markle
it makes sense, i was just blinded by the cancel status i wanted to get from ui, i think i just have to hae a struct to update status always and always check the cancel value from it..now i need to think about the shared status of this
CiNN
+1  A: 

If your platform and development environment supports it some sort of asynchronis messaging system works well. Under Win32 I just use normal windows messages which I "post" (so they don't block the thread) and the standard main message thread of the UI picks up the messages and processes them. I usually define custom messages as well.

Using Timers is suboptimal, there should be no need to "poll" this sort of information.

Osseta