|
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.
|
|
|
|
|
Well put.
It seems like the OP meant to say "when it is necessary" rather than "why it is necessary".
|
|
|
|
|
Cedric Moonen wrote: 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).
Yikes! Please be careful saying things like this to less-experienced developers - just because you never had a reason to do so does not mean that one does not exist. :P
Cedric Moonen wrote: An example of what you can do by overloading these operators is what MFC does: it allows to track memory leaks.
Unless MFC changed recently, I believe this was mostly done by the use of DEBUG_NEW instead of new , and this in turn happened thanks to a #define that was in effect for debug builds. That is not really overloading new ...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: Yikes! Please be careful saying things like this to less-experienced developers - just because you never had a reason to do so does not mean that one does not exist.
That was certainly not my intention. Maybe I expressed myself badly.
|
|
|
|
|
ragavan wrote: why it is necessary to overload new and delete operator
to put some extra printf() inside them for instance !?
|
|
|
|
|
One (the only?) reason is when the objects need to be allocated in a non-standard way. For example, for performance reasons, you may be using per-thread heaps so as to avoid heap contention in a multi-threaded application (if the application is allocation intensive).
Or if you have to allocate lots of smaller-sized objects (< 16-32 bytes) and you need to optimize the allocations by allocating larger blocks and then chunking them yourself. Combining the Win32 heap's and C-RTL's overhead, a heap allocation can have between 20-32 bytes of overhead. So if you need to allocate one million objects of 8 bytes each, this overhead (both space and execution time) can start to add up quickly.
Granted, the average everyday developer does not need to be (or simply is not) concerned with such things, but those are some reasons I have done it in the past.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|