|
-
August 10th, 2005, 02:43 PM
#1
Threads have sequential behavior
Hi,
I have an ATL service(..COINIT_MULTITHREADED) and i include a function which has a loop and create 2 threads ..make some things more and release them..i used CreateThread and waitformutlipleobjects but this code just works in the first loop ..after that i can realize the processing is sequential and even if i try to stop debbuging it tries to debug MSDEV. exe in other VC and throws an exeption..which close both VStudios..here i put my code:
CServiceModuleRun()
{
..
Funcion()....
..
}
void Funcion()
while(loop)
{
phThread = new HANDLE[2];
//if(phThread[0]==NULL)
phThread[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Login, NULL, 0, &idThread);
//if(phThread[1]==NULL)
phThread[1] = CreateThread(NULL, 0,(LPTHREAD_START_ROUTINE)Locales, NULL, 0, &idThread);
WaitForMultipleObjects(2,phThread,true,INFINITE);
GetExitCodeThread(phThread[0], &nRows);
CloseHandle(phThread[0]);
GetExitCodeThread(phThread[1], &nRows);
CloseHandle(phThread[1]);
delete []phThread ;
...
...
}
And i realized about the trace output repeat the thread Id in each iteration..
What i am not considering...
Thanks in advance and 4 the patience...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|