Click here to Skip to main content
15,918,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Class and pointer Pin
Stephen Hewitt10-May-07 19:44
Stephen Hewitt10-May-07 19:44 
QuestionHow to get the width & height of MPEG files with DirectX SDK? Pin
raytracingx10-May-07 18:05
raytracingx10-May-07 18:05 
AnswerRe: How to get the width & height of MPEG files with DirectX SDK? Pin
Hamid_RT11-May-07 0:42
Hamid_RT11-May-07 0:42 
GeneralRe: How to get the width & height of MPEG files with DirectX SDK? Pin
raytracingx13-May-07 16:08
raytracingx13-May-07 16:08 
QuestionApplication Data Directories Pin
Richard Andrew x6410-May-07 18:02
professionalRichard Andrew x6410-May-07 18:02 
QuestionThread parameter use same value for all thread ????? Pin
amitmistry_petlad 10-May-07 17:55
amitmistry_petlad 10-May-07 17:55 
AnswerRe: Thread parameter use same value for all thread ????? Pin
Arman S.10-May-07 20:40
Arman S.10-May-07 20:40 
GeneralRe: Thread parameter use same value for all thread ????? Pin
amitmistry_petlad 10-May-07 21:10
amitmistry_petlad 10-May-07 21:10 
well I say you heartly.
I have been waiting for your answer. if i will write the post with your name then it is not good but i think what i need is what i get.(i mean answer from arman).
ok,
as you know previously about my code the loop is runing and thread created and i have made the array of threads. right.
But now all thread running but the structure variable(structur pointer actually which send the parameter to the Thread function for further process using the same values for all created thread.
e.g

for(int i=0;i<2;i++)
{
  
  struct argument_list *l;//[MAX_PATH];
						  l=(argument_list *)malloc(sizeof(argument_list));
						 
						

						 l->pszInFile=bufferwithpath; 
						 l->pszOutFil=w_Output;
						 l->_ProtectSet=_ProtectSet;
						 l->hList=hList;

						
						 strcpy(l->Host,HOST);
						 l->hwndEncrypt=hwndEncrypt;
						 l->hWndinoutfiledir=hWndinoutfiledir;
						 l->hwndParent=hDlg;		

						 strcpy(l->InitPackageRequest,sINIT_PACKAGE_RESPONSE.c_str());						 
						 l->Port=PORT;

						 strcpy(l->ScriptFile,COMMUNICATOR_SCRIPT_FILE_PATH);

						 strcpy(l->UserID,UserID.c_str());


						 hThread[i]=(HANDLE)_beginthread(&Thread ,0 ,<big><code>l</code></big>);					 
						 //WaitForSingleObject(hThread,INFINITE);
					 }			
					WaitForMultipleObjects(2, hThread, FALSE, INFINITE);

//The value of l remains same for all the created.

means ,The values show correct when the loop is going on.
But when thread call the Thread function below in that case.


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);

all parameter values shown same for all threads .why??? it must be different according to the thread created with.

suppose
for thread one l could be

Lparam->pszInFile ="a.wmv"
Lparam->pszOutFil="DRMa.wmv"
....
.....
.....
.....



for thread 2

Lparam->pszInFile ="b.wmv"
Lparam->pszOutFil="DRMb.wmv"
....
.....
.....
.....


i need this way for consucative thread calls
========
but it shown every time first thread's values for all other thread.

values l for first thread.

Lparam->pszInFile ="a.wmv"
Lparam->pszOutFil="DRMa.wmv"
....
.....
.....
.....



I think now you might got is it ? Wink | ;) Smile | :)


void  Thread(void* pArguments )
{
	if( pArguments == NULL )
	{
	 MessageBox( NULL , _T("Problem in thread") , NULL , IDOK ) ;	
	}
	
	HRESULT hr=NULL;
	<big><code>struct argument_list *Lparam= (argument_list *)pArguments ;</code></big>	Package pkg;
	static int threadID;

	threadID++;		
	{
	 //WaitForSingleObject(GetCurrentThread(),5000);
	  //if(threadID>1)
		//  WaitForSingleObject(GetCurrentThread(),100000);
	    //DWORD ThreadId=GetCurrentThreadId();
<big>//The following function shown me the values same for each new thread </big> 
	  <big><code>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);</code></big>	}

	if(hr==S_OK)
	{	
		MessageBox(0,L"thread gone finished" ,L"therad",0);
		_endthreadex( 0 );    	
	}	
	threadID--;	
}












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

GeneralRe: Thread parameter use same value for all thread ????? Pin
Arman S.11-May-07 0:13
Arman S.11-May-07 0:13 
GeneralRe: Thread parameter use same value for all thread ????? Pin
Arman S.11-May-07 1:01
Arman S.11-May-07 1:01 
GeneralRe: Thread parameter use same value for all thread ????? Pin
amitmistry_petlad 11-May-07 1:15
amitmistry_petlad 11-May-07 1:15 
GeneralRe: Thread parameter use same value for all thread ????? Pin
Arman S.11-May-07 1:44
Arman S.11-May-07 1:44 
GeneralRe: Thread parameter use same value for all thread ????? Pin
Arman S.11-May-07 2:52
Arman S.11-May-07 2:52 
GeneralRe: Thread parameter use same value for all thread ????? Pin
amitmistry_petlad 13-May-07 19:24
amitmistry_petlad 13-May-07 19:24 
GeneralRe: Thread parameter use same value for all thread ????? Pin
amitmistry_petlad 16-May-07 22:55
amitmistry_petlad 16-May-07 22:55 
AnswerRe: Thread parameter use same value for all thread ????? Pin
ThatsAlok17-May-07 1:54
ThatsAlok17-May-07 1:54 
QuestionHow does a MFC process communicate with a .NET process? Pin
talihsu10-May-07 17:08
talihsu10-May-07 17:08 
AnswerRe: How does a MFC process communicate with a .NET process? Pin
led mike10-May-07 18:50
led mike10-May-07 18:50 
GeneralRe: How does a MFC process communicate with a .NET process? Pin
Mark Salsbery11-May-07 6:03
Mark Salsbery11-May-07 6:03 
QuestionRe: How does a MFC process communicate with a .NET process? Pin
Mark Salsbery11-May-07 6:04
Mark Salsbery11-May-07 6:04 
AnswerRe: How does a MFC process communicate with a .NET process? Pin
talihsu13-May-07 7:39
talihsu13-May-07 7:39 
GeneralRe: How does a MFC process communicate with a .NET process? Pin
Mark Salsbery14-May-07 3:50
Mark Salsbery14-May-07 3:50 
GeneralRe: How does a MFC process communicate with a .NET process? Pin
ThatsAlok16-May-07 22:41
ThatsAlok16-May-07 22:41 
QuestionShow drop selection in combobox Pin
amyvt10-May-07 16:35
amyvt10-May-07 16:35 
QuestionBooks and tools for a C newbie Pin
martin_hughes10-May-07 8:53
martin_hughes10-May-07 8:53 

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.