|
Why not?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
May I ask you one more question on thread?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
hum, i'd say go ahead, as we're on the forum for it...
if you don't ask, we won't be able to answer.
but if the question is not respecting the guidelines, be ready to be flamed ! lol
|
|
|
|
|
Thank you sir!
sir when I debug my application. As I debug, all the handles created properly for threads and I have pass the structure pointer (paramters) but value passed through the pointer is same at each call .
what should i do?
should I have to take array of pointers for struct varibale?
-- modified at 9:50 Monday 7th May, 2007
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
i'm not sure i get your english very well...
can you show a piece of code that reproduces the problem ?
|
|
|
|
|
sorry for my english,
better with snippest,
<br />
for(int i=0;i<3;i++)<br />
<br />
<br />
struct argument_list *l ;<br />
l=(argument_list *)malloc(sizeof(argument_list));<br />
<br />
l->pszInFile=bufferwithpath;
l->pszOutFil=w_Output;
<br />
l->_ProtectSet=_ProtectSet;<br />
l->hList=hList;<br />
strcpy(l->Host,HOST);<br />
l->hwndEncrypt=hwndEncrypt;<br />
l->hWndinoutfiledir=hWndinoutfiledir;<br />
l->hwndParent=hDlg; <br />
<br />
strcpy(l->InitPackageRequest,sINIT_PACKAGE_RESPONSE.c_str()); <br />
l->Port=PORT;<br />
<br />
strcpy(l->ScriptFile,COMMUNICATOR_SCRIPT_FILE_PATH);<br />
<br />
strcpy(l->UserID,UserID.c_str()); <br />
hThread[i]=(HANDLE)_beginthread(&Thread ,0 , l );<br />
}<br />
<br />
WaitForMultipleObjects(3, hThread, FALSE, INFINITE);<br />
<br />
below is thread function.
<br />
void Thread(void* pArguments )<br />
{<br />
if( pArguments == NULL )<br />
{<br />
MessageBox( NULL , _T("Problem in thread") , NULL , IDOK ) ;<br />
<br />
}<br />
<br />
HRESULT hr=NULL;<br />
struct argument_list *Lparam= (argument_list *)pArguments ;<br />
Package pkg;<br />
static int threadID;<br />
threadID++;<br />
<br />
<big>{ <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 />
}</big><br />
<br />
<br />
<br />
if(hr==S_OK)<br />
{ <br />
MessageBox(0,L"thread gone finished" ,L"therad",0);<br />
_endthreadex( 0 ); <br />
}<br />
<br />
threadID--;<br />
<br />
}<br />
<br />
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
amitmistry_petlad wrote: l->pszInFile=bufferwithpath; //each time got the same values in the thread function.
l->pszOutFil=w_Output; //time got the same values in the thread function.
If you put the same values in your argument_list structs, then you'll get the same values in
every thread proc.
Unless something is missing in the code you posted, I can't see you putting anything different
in the 3 structs.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
sir, I have made the walkthru but it is some what long so I afrid to put it in the
fouram.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
OK. But you show this in your code...
l->pszInFile=bufferwithpath; //each time got the same values in the thread function.
l->pszOutFil=w_Output; //time got the same values in the thread function.
If these values are the same all three iterations through the loop, and you don't expect them
to be the same, then that's the problem.
My point is, you don't show where those values come from in your code so we can't help you with
that part
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: l->pszInFile=bufferwithpath; //each time got the same values in the thread function.
l->pszOutFil=w_Output; //time got the same values in the thread function.
Dear mark,
for the above I got the values different but when the therad started and go in the thread function there is one function which I shown bold that shown me the same value each time and call that function with same value .
suppose.
there are two thread and both call the function Thread . in loop when the values shown different in structure pointer l but when thread call each it get the last value of listview. it means first values for each thread called in the structure pointer l . how can i handle that one?
can you give me some guideline.Please ...
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
amitmistry_petlad wrote: there are two thread and both call the function Thread
I'm not sure what you mean here. Thread should not be called by anything. It is a threadproc and
the code in it should run when you call _beginthreadex().
amitmistry_petlad wrote: but when thread call each it get the last value of listview.
If you are passing a structure pointer into the thread then you should be getting values from
there. Why would multiple threads be accessing a listview?
This is something you have to debug. Get it working with one thread then try multiple threads.
I don't know what's going on in the function you showed in bold, but everything you do in there
needs to be thread safe - any objects that ca't be accessed simultaneously need to be protected
with thread synchronization objects of some kind.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Dear mark yesterday I have found the solution for that.I have used some handles. that handle sendmessage to the main window but due to the waitformultipleobject stoping the
message processing so I am try to implement MsgWaitForMultipleObjects. Thanks Nave he given me guideline.But can you give me the exact position where should I have call this function?
In Thread function or in mainthread where I had create my worker thread where ? where ? where?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
amitmistry_petlad wrote: n Thread function or in mainthread where I had create my worker thread where ? where ? where?
isn't break point working!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
CPallini wrote: Why not?
will try [ ]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
amitmistry_petlad wrote: can I debug multithreading application?
Yes.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
amitmistry_petlad wrote: hi !
Hi!
amitmistry_petlad wrote: sorry to ask a question on thread.
That's okay.
amitmistry_petlad wrote: can I debug multithreading application?
Yo!
"The difficulty lies, not in the new ideas, but in escaping from the old ones."
-- John Maynard Keyes, 1936
|
|
|
|
|
Your answer is exactly to question very similar but whats meaning of "Yo"?
|
|
|
|
|
by "Yo", he meant "Ya" with a mouth getting closed... get what i mean ?
|
|
|
|
|
Hi
Can anyone tell me the difference between constant pointer and pointer to a constant. Please tell me the situation in which they are used.
Thanks in advance
|
|
|
|
|
|
ragavan wrote: difference between constant pointer and pointer to a constant
isn't what you say descriptive enough ?!
a const pointer cannot be modified, while a pointer to const points to a memory ary which is read-only
|
|
|
|
|
|
Hi
Can anyone tell me why it is necessary to overload new and delete operator
Thanks in advance
|
|
|
|
|
ragavan wrote: Can anyone tell me why it is necessary to overload new and delete operator
It is certainly not necessary to overload these operators. It can be done, sure, but it is never needed. I never did that myself (and I don't see a reason why I would do so).
An example of what you can do by overloading these operators is what MFC does: it allows to track memory leaks.
|
|
|
|