Click here to Skip to main content
16,018,534 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: reading the active font in a window Pin
Waldermort23-Aug-06 15:44
Waldermort23-Aug-06 15:44 
AnswerRe: reading the active font in a window Pin
jk chan23-Aug-06 16:26
jk chan23-Aug-06 16:26 
GeneralRe: reading the active font in a window Pin
phani_8926-Aug-06 1:38
phani_8926-Aug-06 1:38 
JokeI wrote a JumpTigger(or you may call it webspider) for Windows Live Space~ Pin
Artex_xh23-Aug-06 13:45
Artex_xh23-Aug-06 13:45 
GeneralRe: I wrote a JumpTigger(or you may call it webspider) for Windows Live Space~ Pin
Rage23-Aug-06 21:19
professionalRage23-Aug-06 21:19 
QuestionIs it possible to send files through Telnet? Pin
Lord Kixdemp23-Aug-06 13:40
Lord Kixdemp23-Aug-06 13:40 
AnswerRe: Is it possible to send files through Telnet? Pin
Mike Dimmick23-Aug-06 13:55
Mike Dimmick23-Aug-06 13:55 
QuestionSemaphore count Pin
Julberto Danray23-Aug-06 10:56
Julberto Danray23-Aug-06 10:56 
Does anyone know how to determine the current count associated with a semaphore?

Let me explain. I have a server app that creates a background thread every time a client app makes a request. Before each background thread is created my app goes through ::WaitForSingleObject(m_hSemaphore, INFINITE) to ensure that I do not exceed a safe number of concurrent threads. When the background thread finishes its work, it calls ::ReleaseSemaphore(m_hSemaphore, 1, NULL) to balance the semaphore count.

There are times that I need to wait for all background threads to end (for example when the program ends). If I could check for the current semaphore count, I would know how many background threads are still running.

Currently I'm keeping a counter (protected with a critical section) that is incremented when the background thread starts and decremented when it ends. This works but it seems somewhat silly since this information is implicit in the semaphore object.

There is yet another possibility, The 3rd argument of ::ReleaseSemaphore() is a pointer to a LONG that receives the previous count. However, it seems to me that there is a problem here since you have several threads writing to this LONG at about the same time without any thread synchronization mechanism. Semanticaly, I need something like ::GetSemaphoreCount(m_hSemaphore). So far as I know such function does not exist.

Thanks,
Julberto Danray
AnswerRe: Semaphore count Pin
Michael Dunn23-Aug-06 12:13
sitebuilderMichael Dunn23-Aug-06 12:13 
AnswerRe: Semaphore count Pin
Julberto Danray23-Aug-06 14:10
Julberto Danray23-Aug-06 14:10 
AnswerRe: Semaphore count Pin
Joe Woodbury23-Aug-06 12:17
professionalJoe Woodbury23-Aug-06 12:17 
GeneralRe: Semaphore count Pin
Julberto Danray23-Aug-06 16:16
Julberto Danray23-Aug-06 16:16 
GeneralRe: Semaphore count Pin
Joe Woodbury23-Aug-06 16:45
professionalJoe Woodbury23-Aug-06 16:45 
AnswerRe: Semaphore count Pin
tyftyftyf22-Nov-09 16:03
tyftyftyf22-Nov-09 16:03 
QuestionDoes anybody recognise this... Pin
Waldermort23-Aug-06 10:36
Waldermort23-Aug-06 10:36 
AnswerRe: Does anybody recognise this... Pin
Rick York23-Aug-06 11:29
mveRick York23-Aug-06 11:29 
GeneralRe: Does anybody recognise this... Pin
Waldermort23-Aug-06 12:42
Waldermort23-Aug-06 12:42 
GeneralRe: Does anybody recognise this... Pin
Rage23-Aug-06 21:20
professionalRage23-Aug-06 21:20 
GeneralRe: Does anybody recognise this... Pin
Waldermort24-Aug-06 4:31
Waldermort24-Aug-06 4:31 
QuestionSetting edit box color Pin
Oliver12323-Aug-06 10:01
Oliver12323-Aug-06 10:01 
AnswerRe: Setting edit box color Pin
eusto23-Aug-06 10:13
eusto23-Aug-06 10:13 
AnswerRe: Setting edit box color Pin
David Crow23-Aug-06 10:29
David Crow23-Aug-06 10:29 
AnswerRe: Setting edit box color Pin
Hamid Taebi24-Aug-06 0:51
professionalHamid Taebi24-Aug-06 0:51 
QuestionHow can I get Windows installation date ? Pin
koloporanistka23-Aug-06 8:25
koloporanistka23-Aug-06 8:25 
AnswerRe: How can I get Windows installation date ? Pin
Jun Du23-Aug-06 8:40
Jun Du23-Aug-06 8:40 

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.