just one question. I need your little help. when and how the thread manage? Suppose I have four thread hThread[0] = (HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, &threadID); hThread[1] = (HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, &threadID); hThread[2] = (HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, &threadID); hThread[3] = (HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, &threadID); and the global function
unsigned __stdcall Thread(void* pArguments )
{
HRESULT hr=NULL;
struct argument_list *Lparam= (argument_list *)pArguments ;
Package pkg;
threadID++;
DWORD dw=WaitForMultipleObjects(ListBoxItemCount,hThread[threadID],TRUE,5000 );
switch (dw)
{
case WAIT_OBJECT_0 + 0:
// a process with h[0] descriptor has exited
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);
break;
case WAIT_OBJECT_0 + 1:
// a process with h[1] descriptor has exited
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);
break;
case WAIT_OBJECT_0 + 2:
// a process with h[2] descriptor has exited
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);
break;
case WAIT_FAILED:
// failure
break;
case WAIT_TIMEOUT:
// no processes exited during 5000ms
break;
}
//printf( "In second thread...\n" );
if(hr==S_OK)
{
MessageBox(0,L"thread gone finished" ,L"therad",0);
_endthreadex( 0 );
}
threadID--;
return 0;
}
how can i decide the when which thread come at hThread[],
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India