Click here to Skip to main content
15,923,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionError message Pin
vanishaa2-Mar-09 2:26
vanishaa2-Mar-09 2:26 
AnswerRe: Error message Pin
CPallini2-Mar-09 2:54
mveCPallini2-Mar-09 2:54 
AnswerRe: Error message Pin
David Crow2-Mar-09 3:06
David Crow2-Mar-09 3:06 
GeneralRe: Error message Pin
vanishaa2-Mar-09 3:13
vanishaa2-Mar-09 3:13 
GeneralRe: Error message Pin
David Crow2-Mar-09 3:16
David Crow2-Mar-09 3:16 
GeneralRe: Error message Pin
vanishaa2-Mar-09 3:28
vanishaa2-Mar-09 3:28 
GeneralRe: Error message Pin
David Crow2-Mar-09 3:31
David Crow2-Mar-09 3:31 
Questionparellel mutithread problem Pin
JackPuppy2-Mar-09 1:53
JackPuppy2-Mar-09 1:53 
hi, there
It's my first time to post a question here to ask for help because the problem is drving me crazy. Everyone who give a direct answer or redirect-url resources is appreciable.

here is the problem:

I decide to grab web-pages from a website, what my policy is that I use a main thread to find many items in a page and i send each item to a thread to deal with. So this is a parallel muti-thread problem. and I find out that the whole process stuck somewhere and the usage of the CPU climed up to 100%. here is the main code that i think is asscociated:
<pre>
HANDLE hSemaThr,hSema,hContent;

main(){

....Handle hCont=CreateFile(....);
hSema=CREATESemaphore(0,1,1,0);
hSemaThr=CREATEMUTEX(0,10,10,0);//this Semaphore is to control thread-buildings so that there are 10 threads in the process at most
WHILE(regex_search(begin,end,stringmatch,r)){
string s=stringmatch[0];
begin=stringmatch[0].second;


WaitForSingleObject(hSemaThr,INFINITE);
CreateThread(0,0,Grab,(void*)dc,0,0);

}

CloseHandle(hCont);
}

void Grab(void* doc){

......
......

WaitForSingleObject(hSema,INFINITE);
if(!WriteFile(::hCont,lpBuf,(int)strlen(lpBuf),&lpN,0)){
cout < <"can't write file in thread" < <GetLastError() < <endl;
//system("pause");

}
ReleaseSemaphore(hSema,1,0);

WaitForSingleObject(hMutexThr,INFINITE);
CanThr--;
ReleaseSemaphore(hSemaThr,1,0);

}
</pre>
Can somebody help me!
Thanks very much!

--Jack
AnswerRe: parellel mutithread problem Pin
Code-o-mat2-Mar-09 2:15
Code-o-mat2-Mar-09 2:15 
GeneralRe: parellel mutithread problem Pin
JackPuppy2-Mar-09 2:31
JackPuppy2-Mar-09 2:31 
GeneralRe: parellel mutithread problem Pin
Code-o-mat2-Mar-09 2:36
Code-o-mat2-Mar-09 2:36 
Questionhow to include a paneld inside the client area in SDI architect? Pin
Joseph Marzbani2-Mar-09 1:25
Joseph Marzbani2-Mar-09 1:25 
AnswerRe: how to include a paneld inside the client area in SDI architect? Pin
Stuart Dootson2-Mar-09 3:32
professionalStuart Dootson2-Mar-09 3:32 
GeneralRe: how to include a paneld inside the client area in SDI architect? Pin
Joseph Marzbani2-Mar-09 6:59
Joseph Marzbani2-Mar-09 6:59 
QuestionHow C++ read one digit each time from a sequence of digits? Pin
followait2-Mar-09 0:28
followait2-Mar-09 0:28 
AnswerRe: How C++ read one digit each time from a sequence of digits? Pin
_AnsHUMAN_ 2-Mar-09 0:37
_AnsHUMAN_ 2-Mar-09 0:37 
GeneralRe: How C++ read one digit each time from a sequence of digits? Pin
followait2-Mar-09 0:38
followait2-Mar-09 0:38 
GeneralRe: How C++ read one digit each time from a sequence of digits? Pin
_AnsHUMAN_ 2-Mar-09 0:48
_AnsHUMAN_ 2-Mar-09 0:48 
GeneralRe: How C++ read one digit each time from a sequence of digits? Pin
followait2-Mar-09 0:57
followait2-Mar-09 0:57 
AnswerRe: How C++ read one digit each time from a sequence of digits? Pin
David Crow2-Mar-09 3:48
David Crow2-Mar-09 3:48 
QuestionRemote COM Pin
RevathiRamakumar2-Mar-09 0:14
RevathiRamakumar2-Mar-09 0:14 
AnswerRe: Remote COM Pin
CPallini2-Mar-09 0:26
mveCPallini2-Mar-09 0:26 
GeneralRe: Remote COM Pin
RevathiRamakumar2-Mar-09 0:29
RevathiRamakumar2-Mar-09 0:29 
QuestionRe: Remote COM Pin
CPallini2-Mar-09 0:34
mveCPallini2-Mar-09 0:34 
AnswerRe: Remote COM Pin
RevathiRamakumar2-Mar-09 0:42
RevathiRamakumar2-Mar-09 0:42 

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.