Click here to Skip to main content
15,910,471 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: What IDE is good for developing GUI apps using C++? Pin
Greg Utas29-May-22 8:18
professionalGreg Utas29-May-22 8:18 
GeneralRe: What IDE is good for developing GUI apps using C++? Pin
Calin Negru29-May-22 8:34
Calin Negru29-May-22 8:34 
AnswerRe: What IDE is good for developing GUI apps using C++? Pin
Joe Woodbury29-May-22 13:44
professionalJoe Woodbury29-May-22 13:44 
AnswerRe: What IDE is good for developing GUI apps using C++? Pin
Richard MacCutchan29-May-22 22:12
mveRichard MacCutchan29-May-22 22:12 
AnswerRe: What IDE is good for developing GUI apps using C++? Pin
Gerry Schmitz30-May-22 6:12
mveGerry Schmitz30-May-22 6:12 
Questionvector and Template confusion Pin
T Bones Jones23-May-22 7:33
T Bones Jones23-May-22 7:33 
AnswerRe: vector and Template confusion Pin
Victor Nijegorodov23-May-22 8:09
Victor Nijegorodov23-May-22 8:09 
GeneralRe: vector and Template confusion Pin
T Bones Jones23-May-22 8:12
T Bones Jones23-May-22 8:12 
AnswerRe: vector and Template confusion Pin
CPallini23-May-22 22:02
mveCPallini23-May-22 22:02 
GeneralRe: vector and Template confusion Pin
T Bones Jones24-May-22 4:24
T Bones Jones24-May-22 4:24 
GeneralRe: vector and Template confusion Pin
CPallini24-May-22 20:02
mveCPallini24-May-22 20:02 
AnswerRe: vector and Template confusion Pin
Richard MacCutchan23-May-22 22:03
mveRichard MacCutchan23-May-22 22:03 
GeneralRe: vector and Template confusion Pin
T Bones Jones24-May-22 4:33
T Bones Jones24-May-22 4:33 
GeneralRe: vector and Template confusion Pin
Richard MacCutchan24-May-22 5:02
mveRichard MacCutchan24-May-22 5:02 
GeneralRe: vector and Template confusion Pin
T Bones Jones24-May-22 5:08
T Bones Jones24-May-22 5:08 
GeneralRe: vector and Template confusion Pin
Richard MacCutchan24-May-22 5:11
mveRichard MacCutchan24-May-22 5:11 
QuestionApplication check for virus Pin
Gopi Nath23-May-22 1:18
Gopi Nath23-May-22 1:18 
AnswerRe: Application check for virus Pin
Richard MacCutchan23-May-22 1:25
mveRichard MacCutchan23-May-22 1:25 
AnswerRe: Application check for virus Pin
Dave Kreskowiak23-May-22 2:16
mveDave Kreskowiak23-May-22 2:16 
AnswerRe: Application check for virus Pin
Gopi Nath23-May-22 18:30
Gopi Nath23-May-22 18:30 
QuestionSetting Font and Text Colors items of ComboBox Pin
ForNow22-May-22 12:32
ForNow22-May-22 12:32 
AnswerRe: Setting Font and Text Colors items of ComboBox Solved almost Pin
ForNow22-May-22 13:28
ForNow22-May-22 13:28 
GeneralRe: Setting Font and Text Colors items of ComboBox Solved almost Pin
Victor Nijegorodov22-May-22 20:14
Victor Nijegorodov22-May-22 20:14 
GeneralRe: Setting Font and Text Colors items of ComboBox Solved almost Pin
ForNow22-May-22 22:26
ForNow22-May-22 22:26 
QuestionAccessing and displaying semaphore count Pin
coco24322-May-22 1:42
coco24322-May-22 1:42 
Hi,

In my trying on understanding semaphores I am looking on the following example:

C++
DWORD WINAPI ChildThreadProc( HWND hWnd )
{
	TCHAR szBuffer[256];          // buffer
	DWORD dwSemCount = 0;         // printing semaphore count
	HANDLE hSemaphore = OpenSemaphore( SYNCHRONIZE, FALSE, "TEST SEMAPHORE");
	wsprintf(szBuffer, "Thread %x waiting for semaphore %x", GetCurrentThreadId(), hSemaphore );
	SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer);
	// Check for signaled semaphore
	WaitForSingleObject( hSemaphore, INFINITE );
	wsprintf(szBuffer, "Thread %x got semaphore", GetCurrentThreadId() );
	SendMessage(hWnd, WM_USER, 0, (LPARAM)szBuffer);
	Sleep(5000);
	//dwSCount = dwSemCount;
	//Release semaphore
	ReleaseSemaphore( hSemaphore, 1, (LPLONG)&dwSCount );
	wsprintf( szBuffer, "Thread %x is done with semaphore. Its count was %ld.", GetCurrentThreadId(), dwSemCount );
	SendMessage( hWnd, WM_USER, 0, (LPARAM)szBuffer );
	CloseHandle( hSemaphore );
	ExitThread ( TRUE );
}


And I am having 2 problems here:

-first, the dwSemCount value si always printed as 0, even if the semaphore works fine
-second, incrementing the counter with ReleaseSemaphore function from inside of thread doesn't working, I can't explain why.

Can you please help me with some advices?

Thank you very much,

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.