Maximus said:
I'm trying to create a thread (never did before) to constantly look at a
combo box value but my thread take 100% of the processor, a thing I don't
want to. First is it normal and second if first is no what's my error in my
codes:
Firstly, you have a busy loop: while(1). That's what trashes your CPU - it
spends all its time servicing your thread, unaware it's not doing anything.
Secondly, if you absolutely must thread, use _beginthread(), not
CreateThread(). The former initializes the thread's C runtime library
features.
Thirdly, our industry horribly over-uses threads. Your documentation will
not tell you this, but the only reason to ever use them are certain hardware
and device driver shenanigans.
Fourth, the point of GUI programming is to write "event driven" code. When
that combo box changes it is already sending your window several messages
describing exactly how it change. If your code simply declared handlers for
these notifications (search for WM_NOTIFY to learn how), then you could
write a small function that only does exactly want you need with the event.
Using events to drive programs tends to force your code to use a complete
object model to store all its facts, and this technique makes threads very
unlikely.
Fifth, all this is off-topic here. Other newsgroups are better qualified to
help with platform-specific code. We try to only discuss platform-neutral
topics. (But those newsgroups might not advise against threads!)