Click here to Skip to main content
15,912,493 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CreateFont() Pin
Poorniselva4-Jul-04 23:58
Poorniselva4-Jul-04 23:58 
GeneralRe: CreateFont() Pin
Poorniselva5-Jul-04 0:04
Poorniselva5-Jul-04 0:04 
QuestionCPropertySheet: How to add a maximize button only? Pin
mcbain4-Jul-04 21:38
mcbain4-Jul-04 21:38 
GeneralSniffing Net Usage Pin
Tarundeep Singh Kalra4-Jul-04 21:20
Tarundeep Singh Kalra4-Jul-04 21:20 
GeneralRe: Sniffing Net Usage Pin
Antony M Kancidrowski4-Jul-04 23:36
Antony M Kancidrowski4-Jul-04 23:36 
GeneralRe: Sniffing Net Usage Pin
Mayank Goyal5-Jul-04 0:28
Mayank Goyal5-Jul-04 0:28 
QuestionPainting: Thread and OnTimer OR Thread and DC ? Pin
Danoo4-Jul-04 21:10
Danoo4-Jul-04 21:10 
AnswerRe: Painting: Thread and OnTimer OR Thread and DC ? Pin
Johann Gerell4-Jul-04 22:07
Johann Gerell4-Jul-04 22:07 
Danoo wrote:
- Have a WorkerThread that prepares data and an OnTimer handler that displays the data if modified

Sure, you can have a worker thread preparing data. The OnTimer() should be in the GUI thread, though. You must however, of course, correctly synchronize access to shared data.

Danoo wrote:
- Having a WorkerThread that holds a handle to a DC (or maybe memDC) that paints to the window whenever he thinks its due.

If you keep a DC and use it to paint in, then it's not a worker thread in my point of view, but a GUI thread. A memory DC might pass as appropriate in some extreme cases. But don't use multiple GUI threads. Just don't.

Before you think about any other alternative - are you following the #1 rule of optimization?

Dont't optimize until you have actually measured that it's necessary!

Just lowering the CPU usage is not a justified reason to optimize. Is the CPU usage too high? That's the question.

Danoo wrote:
Which approach do you use ?

Given the fact that I must optimize, I tend to stick to one thread only, unless the amount of number crunching required to update the GUI is massive.

I would probably use a class or private DC, since they exist for that particular purpose. When the timer fires, I would invalidate only changed areas and paint what I'd prepared between the timer events.

--
Dad, how strange it is that the pig can speak.
*thoughtful pause* It must have lost its "oink".
(my 3-year old daughter Moa, while watching Babe)

Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so. (Douglas Adams)

AnswerRe: Painting: Thread and OnTimer OR Thread and DC ? Pin
Antti Keskinen4-Jul-04 22:13
Antti Keskinen4-Jul-04 22:13 
GeneralExplorer volume information Pin
Pheonix4-Jul-04 20:30
Pheonix4-Jul-04 20:30 
GeneralRe: Explorer volume information Pin
Graham Bradshaw4-Jul-04 23:51
Graham Bradshaw4-Jul-04 23:51 
GeneralRe: Explorer volume information Pin
Pheonix5-Jul-04 3:12
Pheonix5-Jul-04 3:12 
GeneralRe: Explorer volume information Pin
Graham Bradshaw5-Jul-04 3:14
Graham Bradshaw5-Jul-04 3:14 
GeneralRe: Explorer volume information Pin
Pheonix5-Jul-04 4:14
Pheonix5-Jul-04 4:14 
GeneralRe: Explorer volume information Pin
Graham Bradshaw5-Jul-04 3:23
Graham Bradshaw5-Jul-04 3:23 
QuestionHow to add control on a Button? Pin
Rajesh_K_Sharma4-Jul-04 20:07
Rajesh_K_Sharma4-Jul-04 20:07 
AnswerRe: How to add control on a Button? Pin
Antti Keskinen4-Jul-04 21:09
Antti Keskinen4-Jul-04 21:09 
GeneralRe: How to add control on a Button? Pin
Rajesh_K_Sharma5-Jul-04 23:15
Rajesh_K_Sharma5-Jul-04 23:15 
GeneralRe: How to add control on a Button? Pin
Antti Keskinen6-Jul-04 5:24
Antti Keskinen6-Jul-04 5:24 
Generalhide menubar Pin
s o v a n n4-Jul-04 20:01
s o v a n n4-Jul-04 20:01 
GeneralRe: hide menubar Pin
A T I F4-Jul-04 21:49
A T I F4-Jul-04 21:49 
GeneralRe: hide menubar Pin
s o v a n n5-Jul-04 1:56
s o v a n n5-Jul-04 1:56 
GeneralWM_QUERYENDSESSION problems Pin
Mayank Goyal4-Jul-04 19:39
Mayank Goyal4-Jul-04 19:39 
Generaldetermine the End of video file Pin
Anonymous4-Jul-04 19:24
Anonymous4-Jul-04 19:24 
Generali need to make some 256x256 bitmaps from lots of other bitmaps Pin
Slim Gradey4-Jul-04 18:03
Slim Gradey4-Jul-04 18:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.