Click here to Skip to main content
16,004,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Background text color in RichEditCtrl Pin
Scott Holt27-Nov-06 15:17
Scott Holt27-Nov-06 15:17 
QuestionThread Colsing Problem Pin
Sunil Lanke26-Nov-06 21:50
Sunil Lanke26-Nov-06 21:50 
AnswerRe: Thread Colsing Problem Pin
CPallini26-Nov-06 22:50
mveCPallini26-Nov-06 22:50 
AnswerRe: Thread Colsing Problem Pin
Roger Stoltz27-Nov-06 0:11
Roger Stoltz27-Nov-06 0:11 
GeneralRe: Thread Colsing Problem Pin
spielehelfer27-Nov-06 3:53
spielehelfer27-Nov-06 3:53 
GeneralRe: Thread Colsing Problem Pin
Roger Stoltz27-Nov-06 5:22
Roger Stoltz27-Nov-06 5:22 
GeneralRe: Thread Colsing Problem Pin
spielehelfer27-Nov-06 21:48
spielehelfer27-Nov-06 21:48 
GeneralRe: Thread Colsing Problem Pin
Roger Stoltz28-Nov-06 3:19
Roger Stoltz28-Nov-06 3:19 
My first post I suggested an alternative design solution for the OP, since I'm under the impression that he had selected the wrong solution for the problem.
You don't paint the walls with a hammer.
In my second post I was really trying to help you to avoid troubles in your way of doing multithreaded applications.

spielehelfer wrote:
- I thought its well known whats able to fill 'params' with
- the Threadobject would be deleted after the loop jumps out, what happens when the thread has ended (I didnt write it, ok).


Ok, so noted.
A word of caution though: don't assume that the person you're trying to help is aware of things you consider 'common knowledge'. In my opinion it's hard enough to help someone while guessing their level of expertise.

spielehelfer wrote:
- that the Sleep() is no 100% secure statement for a threadchange ist true


True, in fact it might be quite the opposite: it's almost 100% wrong to use ::Sleep() in this situation. ::Sleep(0) would make a little more sense but it would still not be quite right.
Read the timing section [^] of Joe Newcomer's article and you will know why afterwards.

spielehelfer wrote:
- to secure the application for deadlocks, there are several locking mechanism possible so secure shared variables


Suspicious | :suss:
A "deadlock" and "corrupt data due to multiple threads accessing the same data" are two very different problems, but both are related to multithreading.
Protecting shared data is often called "thread synchronization".
You cannot prevent deadlocks by the use of thread synchronization; you may, however, cause a deadlock by improper use of thread synchronization.


spielehelfer wrote:
- WaitForSingleObject has the problem that it locks up the application that calls it if used tirect in a window creating code, thats why i used a loop


If it's the blocking part you worry about I can tell you that your loop solution is worse. (Calling ::Sleep()!) :->
It really doesn't matter: you should use ::WaitForSingleObject(), or ::WaitForMultipleObjects(), for multiple reasons (the ones below at the top of my head):
1. you can set a timeout
2. the waiting function consumes a very small amount of CPU cycles
3. the calling thread's priority gets boosted temporarily when any of the handles waiting for reaches its signalled state
4. you really don't want to process messages during this time to prevent other problems with re-entrancy
If you want to read more about why it's wrong to use ::GetThreadExitCode(), have a look here[^].


spielehelfer wrote:
Well Im not a code guru, dont think Im one and also theres every time someone that knows more than me


Quite allright! Rose | [Rose]
However, I strongly advise you to read Joe Newcomer's articles about how to use worker threads here[^] and the other ones I suggested above from his MVP tips page, http://www.flounder.com/mvp_tips.htm[^].

Cheers
--
Roger


"It's supposed to be hard, otherwise anybody could do it!" - selfquote

"No one remembers a coward!" - Jan Elfström 1998
"...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above

QuestionWTL Pin
Anilkumar K V26-Nov-06 21:43
Anilkumar K V26-Nov-06 21:43 
AnswerRe: WTL Pin
toxcct26-Nov-06 22:12
toxcct26-Nov-06 22:12 
QuestionFree Book MFC internals by scott wingo [modified] Pin
Neo Andreson26-Nov-06 21:42
Neo Andreson26-Nov-06 21:42 
AnswerRe: Book MFC internals by scott wingo Pin
S Douglas26-Nov-06 22:07
professionalS Douglas26-Nov-06 22:07 
AnswerRe: Book MFC internals by scott wingo Pin
toxcct26-Nov-06 22:13
toxcct26-Nov-06 22:13 
QuestionRe: Free Book MFC internals by scott wingo Pin
David Crow27-Nov-06 5:21
David Crow27-Nov-06 5:21 
QuestionUnusual problem Pin
harsha_123426-Nov-06 21:33
harsha_123426-Nov-06 21:33 
AnswerRe: Unusual problem Pin
David Crow27-Nov-06 5:23
David Crow27-Nov-06 5:23 
QuestionHow to change the file version of o/p exe file property in VC .Net [modified] Pin
rp_suman26-Nov-06 21:30
rp_suman26-Nov-06 21:30 
AnswerRe: How to change the file version of o/p exe file property in VC .Net Pin
XtremDev26-Nov-06 21:32
XtremDev26-Nov-06 21:32 
QuestionHow to get memory usage of my program using ToolHelp32-API Pin
cy163@hotmail.com26-Nov-06 21:21
cy163@hotmail.com26-Nov-06 21:21 
Question"Paint" Separator on Dialog? Pin
bosfan26-Nov-06 21:05
bosfan26-Nov-06 21:05 
AnswerRe: "Paint" Separator on Dialog? Pin
XtremDev26-Nov-06 21:22
XtremDev26-Nov-06 21:22 
GeneralRe: "Paint" Separator on Dialog? [modified] Pin
bosfan27-Nov-06 2:16
bosfan27-Nov-06 2:16 
GeneralRe: "Paint" Separator on Dialog? Pin
XtremDev27-Nov-06 3:40
XtremDev27-Nov-06 3:40 
GeneralRe: "Paint" Separator on Dialog? Pin
bosfan27-Nov-06 4:05
bosfan27-Nov-06 4:05 
AnswerRe: "Paint" Separator on Dialog? Pin
David Crow27-Nov-06 5:42
David Crow27-Nov-06 5:42 

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.