Click here to Skip to main content
15,911,848 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help for using stl::map? Pin
markkuk4-May-07 3:30
markkuk4-May-07 3:30 
Questionesy way to send email in win32 application Pin
sepel3-May-07 21:57
sepel3-May-07 21:57 
AnswerRe: esy way to send email in win32 application Pin
Roger Stoltz3-May-07 22:30
Roger Stoltz3-May-07 22:30 
GeneralRe: esy way to send email in win32 application Pin
sepel4-May-07 1:48
sepel4-May-07 1:48 
AnswerRe: esy way to send email in win32 application Pin
David Crow4-May-07 2:45
David Crow4-May-07 2:45 
QuestionCompile EVC++ 4.0 from command line [modified] Pin
pri_skit3-May-07 21:41
pri_skit3-May-07 21:41 
QuestionSplitDialogTemplate() difference between VC6 and VC2005 Options Pin
RaymondYounan3-May-07 20:54
RaymondYounan3-May-07 20:54 
QuestionNeed little help in Worker threads [modified] Pin
amitmistry_petlad 3-May-07 20:36
amitmistry_petlad 3-May-07 20:36 
Hi!
In my application I am using multithreading.

for that I have used the loop.

HANDLE hThread[3];

<br />
for(int i=0;i<3;i++)<br />
{<br />
hThread[i]=(HANDLE)_beginthreadex(NULL, 0, &Thread ,l,NULL, &threadID);<br />
}<br />
<br />
<br />
unsigned __stdcall Thread(void* pArguments )<br />
{<br />
	HRESULT hr=NULL;<br />
	struct argument_list *Lparam= (argument_list *)pArguments ;<br />
	Package pkg;<br />
	threadID++;<br />
	<br />
	DWORD  dw=WaitForMultipleObjects(ListBoxItemCount,hThread,TRUE,5000 );									 <br />
							<br />
	switch (dw)<br />
	{	  						<br />
	  case WAIT_OBJECT_0 + 0:<br />
	  // a process with h[0] descriptor has exited							      								   <br />
	  hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lparam->Host,Lparam->UserID,Lparam->InitPackageRequest,Lparam->ScriptFile,Lparam->Port,Lparam->hList,Lparam->_ProtectSet,Lparam->hWndinoutfiledir,Lparam->hwndEncrypt);	<br />
	  break;<br />
<br />
	  case WAIT_OBJECT_0 + 1:<br />
	  // a process with h[1] descriptor has exited							      								   <br />
	  hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lparam->Host,Lparam->UserID,Lparam->InitPackageRequest,Lparam->ScriptFile,Lparam->Port,Lparam->hList,Lparam->_ProtectSet,Lparam->hWndinoutfiledir,Lparam->hwndEncrypt);	<br />
	  break;<br />
	<br />
	  case WAIT_OBJECT_0 + 2:<br />
	  // a process with h[2] descriptor has exited							      								   <br />
	  hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lparam->Host,Lparam->UserID,Lparam->InitPackageRequest,Lparam->ScriptFile,Lparam->Port,Lparam->hList,Lparam->_ProtectSet,Lparam->hWndinoutfiledir,Lparam->hwndEncrypt);	<br />
	  break;<br />
<br />
	  case WAIT_FAILED:<br />
	  // failure<br />
	  break;<br />
							<br />
	  case WAIT_TIMEOUT:<br />
	  // no processes exited during 5000ms<br />
	   break;<br />
	}	<br />
    //printf( "In second thread...\n" );    <br />
	if(hr==S_OK)<br />
	{	<br />
	MessageBox(0,L"thread gone finished" ,L"therad",0);<br />
	_endthreadex( 0 );    	<br />
	}<br />
	threadID--;<br />
	return 0;<br />
}

how these worker thread works and how they will run.

means ,how can i identified that which thread work at hThread[threadID/*it is Relevant with i */ ],

1)I have to wait/stop the main thread until the work threads finished his task.
2)when can all thread start. or will it start immidate at the loop time or first it will create all. then it start ?

becuse in my application when i debug some started with loop and some afterwards.








-- modified at 7:09 Friday 4th May, 2007

"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India

AnswerRe: Need little help in Worker threads Pin
Chilli714-May-07 0:52
Chilli714-May-07 0:52 
GeneralRe: Need little help in Worker threads Pin
amitmistry_petlad 4-May-07 1:03
amitmistry_petlad 4-May-07 1:03 
GeneralRe: Need little help in Worker threads Pin
Chilli714-May-07 4:17
Chilli714-May-07 4:17 
AnswerRe: Need little help in Worker threads Pin
Roger Stoltz4-May-07 1:29
Roger Stoltz4-May-07 1:29 
GeneralRe: Need little help in Worker threads Pin
amitmistry_petlad 4-May-07 1:38
amitmistry_petlad 4-May-07 1:38 
QuestionFinger print sensor with mfc Pin
deeps_cute3-May-07 20:13
deeps_cute3-May-07 20:13 
JokeRe: Finger print sensor with mfc Pin
Rajesh R Subramanian3-May-07 20:30
professionalRajesh R Subramanian3-May-07 20:30 
GeneralRe: Finger print sensor with mfc Pin
deeps_cute3-May-07 20:55
deeps_cute3-May-07 20:55 
QuestionRe: Finger print sensor with mfc Pin
Rajesh R Subramanian3-May-07 21:06
professionalRajesh R Subramanian3-May-07 21:06 
AnswerRe: Finger print sensor with mfc Pin
deeps_cute3-May-07 21:27
deeps_cute3-May-07 21:27 
QuestionRe: Finger print sensor with mfc Pin
Rajesh R Subramanian3-May-07 21:41
professionalRajesh R Subramanian3-May-07 21:41 
AnswerRe: Finger print sensor with mfc Pin
Rajesh R Subramanian3-May-07 21:57
professionalRajesh R Subramanian3-May-07 21:57 
GeneralRe: Finger print sensor with mfc Pin
deeps_cute4-May-07 0:22
deeps_cute4-May-07 0:22 
GeneralRe: Finger print sensor with mfc Pin
Rajesh R Subramanian4-May-07 1:33
professionalRajesh R Subramanian4-May-07 1:33 
GeneralRe: Finger print sensor with mfc Pin
Mark Salsbery4-May-07 6:32
Mark Salsbery4-May-07 6:32 
GeneralRe: Finger print sensor with mfc Pin
Rajesh R Subramanian4-May-07 21:09
professionalRajesh R Subramanian4-May-07 21:09 
GeneralRe: Finger print sensor with mfc Pin
Mark Salsbery5-May-07 5:54
Mark Salsbery5-May-07 5:54 

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.