Click here to Skip to main content
15,890,123 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCreateProcess parametr problem. Pin
david bagaturia21-May-07 1:04
david bagaturia21-May-07 1:04 
AnswerRe: CreateProcess parametr problem. Pin
David Crow21-May-07 3:24
David Crow21-May-07 3:24 
QuestionCreateProcess problem. Pin
david bagaturia21-May-07 1:02
david bagaturia21-May-07 1:02 
AnswerRe: CreateProcess problem. Pin
GuyM21-May-07 1:12
GuyM21-May-07 1:12 
GeneralRe: CreateProcess problem. Pin
david bagaturia21-May-07 2:17
david bagaturia21-May-07 2:17 
QuestionRemoving Title Bar from MDI frame Pin
zubair_ahmed21-May-07 0:30
zubair_ahmed21-May-07 0:30 
AnswerRe: Removing Title Bar from MDI frame Pin
Nelek21-May-07 1:14
protectorNelek21-May-07 1:14 
QuestionWaitForSingleObject Query Pin
Vikas K.20-May-07 23:59
Vikas K.20-May-07 23:59 
Hi, I have 2 variants of usage of WaitForSingleObject. Pls tell me which one is the proper usage?

Version1:

<pre>

#include <windows.h>
#include <iostream.h>

HANDLE hEvent;

DWORD WINAPI SampleThread(LPVOID iValue)
{

int iFinish = 120;
for(int i=100;i<=iFinish;i++)
cout<<i<<endl;

SetEvent(hEvent);
return 0;

}

void main()
{

HANDLE hThread;
DWORD dwGenericThread;
hThread = CreateThread(NULL,0,SampleThread,NULL,0,&dwGenericThread);

if(hThread == NULL)
{

DWORD dwError = GetLastError();
cout<<"SCM:Error in Creating thread"<<dwError<<endl ;
return;

}

hEvent = CreateEvent(NULL,FALSE,FALSE,"Test");

cout<<"Started waiting for the thread to complete.."<<endl ;

WaitForSingleObject(hEvent,INFINITE);

cout<<"Thread Completed."<<endl ;

CloseHandle(hEvent);

}

</pre>

Version2:

<code>

// WaitForSingleObj.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

// WaitForSingleObject Sample.cpp


#include <windows.h>
#include <iostream.h>



DWORD WINAPI SampleThread(LPVOID iValue)
{

int iFinish = 120;
for(int i=100;i<=iFinish;i++)
cout<<i<<endl;
return 0;

}

void main()
{

HANDLE hThread;
DWORD dwGenericThread;
hThread = CreateThread(NULL,0,SampleThread,NULL,0,&dwGenericThread);

if(hThread == NULL)
{

DWORD dwError = GetLastError();
cout<<"SCM:Error in Creating thread"<<dwError<<endl ;
return;

}

cout<<"Started waiting for the thread to complete.."<<endl ;

WaitForSingleObject(hThread,INFINITE);

cout<<"Thread Completed."<<endl ;

}
</code>
AnswerRe: WaitForSingleObject Query Pin
GuyM21-May-07 0:20
GuyM21-May-07 0:20 
AnswerRe: WaitForSingleObject Query Pin
Roger Stoltz21-May-07 0:57
Roger Stoltz21-May-07 0:57 
GeneralRe: WaitForSingleObject Query Pin
Vikas K.21-May-07 3:13
Vikas K.21-May-07 3:13 
QuestionWhat "mapping" is all about? Pin
LiYS20-May-07 23:30
LiYS20-May-07 23:30 
QuestionRe: What "mapping" is all about? Pin
GuyM21-May-07 0:22
GuyM21-May-07 0:22 
AnswerRe: What "mapping" is all about? Pin
LiYS21-May-07 0:28
LiYS21-May-07 0:28 
AnswerRe: What "mapping" is all about? Pin
GuyM21-May-07 0:49
GuyM21-May-07 0:49 
GeneralRe: What &quot;mapping&quot; is all about? [modified] Pin
LiYS21-May-07 0:58
LiYS21-May-07 0:58 
QuestionSDI to MDI Pin
Anilkumar K V20-May-07 22:41
Anilkumar K V20-May-07 22:41 
AnswerRe: SDI to MDI Pin
GuyM21-May-07 0:36
GuyM21-May-07 0:36 
Question#include statements Pin
prithaa20-May-07 22:14
prithaa20-May-07 22:14 
AnswerRe: #include statements Pin
Hamid_RT20-May-07 22:27
Hamid_RT20-May-07 22:27 
AnswerRe: #include statements Pin
Perspx21-May-07 8:50
Perspx21-May-07 8:50 
GeneralRe: #include statements Pin
prithaa21-May-07 20:54
prithaa21-May-07 20:54 
QuestionGrabbing a word under the mouse Pin
Waldermort20-May-07 22:01
Waldermort20-May-07 22:01 
AnswerRe: Grabbing a word under the mouse Pin
Hamid_RT20-May-07 22:15
Hamid_RT20-May-07 22:15 
GeneralRe: Grabbing a word under the mouse Pin
Waldermort20-May-07 22:32
Waldermort20-May-07 22:32 

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.