Click here to Skip to main content
15,915,791 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMulti-threaded MFC Webcrawler (VC++) Pin
JonCage30-Mar-04 2:24
JonCage30-Mar-04 2:24 
Hi there, I'm in the process of writing a multi-threaded webcrawler using VC++ 6 and MFC. I've got the basics down, but I can't help feeling like I'm going about it the wrong way.

I've got a Doc/View set up and when the user chooses some options (base URL / how many threads to launch), the document launches the first thread. To do that, it sends a message (using postthreadmessage) to the worker. The worker then goes and downloads the first page, parses it for links and sends a message back to the document via the view as I wasn't able to send them directly to the document...

As a side note, that process feels a little clunky. It seems logical that you'd probably not want to send messages direct to the document, but I couldn't see where else to do it; afterall, the document's storing all the links the workers download.

...anyway, once the document knows there's an idle worker, it gets all the links from the worker (calls a member function on it to retrieve the data - should be safe as the worker is idling now?) and adds them onto the (end of) master list. Since the document knows there's now a free worker, it pulls off the next link on the master link and launches the worker off again.

Does this sound like a reasonable way of doing things? I'm not sure quite why, but it feels a little in-elegant, and I can't help feeling there's probably a better way of doing it?

Any suggestions / comments would be most welcome!

Cheers, Jon

Success is 99% failure
GeneralRe: Multi-threaded MFC Webcrawler (VC++) Pin
ohadp30-Mar-04 3:21
ohadp30-Mar-04 3:21 
GeneralWriting editors for indian languages Pin
Sivaji30-Mar-04 2:09
Sivaji30-Mar-04 2:09 
GeneralRe: Writing editors for indian languages Pin
Monty230-Mar-04 2:24
Monty230-Mar-04 2:24 
GeneralRe: Writing editors for indian languages Pin
Sivaji30-Mar-04 17:39
Sivaji30-Mar-04 17:39 
GeneralShorcut menu Pin
CZECH REPUBLIC30-Mar-04 1:47
sussCZECH REPUBLIC30-Mar-04 1:47 
GeneralRe: Shorcut menu Pin
22491730-Mar-04 2:02
22491730-Mar-04 2:02 
GeneralRe: Shorcut menu Pin
Prakash Nadar30-Mar-04 2:37
Prakash Nadar30-Mar-04 2:37 
GeneralWriting Excel files... Pin
Matt Gullett30-Mar-04 1:29
Matt Gullett30-Mar-04 1:29 
GeneralRe: Writing Excel files... Pin
Antti Keskinen30-Mar-04 2:42
Antti Keskinen30-Mar-04 2:42 
GeneralRe: Writing Excel files... Pin
BlackDice30-Mar-04 3:16
BlackDice30-Mar-04 3:16 
GeneralRead and writing access (*.mdb) file with Record view form! Pin
Mehdi_Hosseinpour30-Mar-04 1:25
Mehdi_Hosseinpour30-Mar-04 1:25 
GeneralRe: Read and writing access (*.mdb) file with Record view form! Pin
Antti Keskinen30-Mar-04 2:54
Antti Keskinen30-Mar-04 2:54 
GeneralRe: Read and writing access (*.mdb) file with Record view form! Pin
David Crow30-Mar-04 3:41
David Crow30-Mar-04 3:41 
GeneralRe: Read and writing access (*.mdb) file with Record view form! Pin
Alexander M.,30-Mar-04 7:27
Alexander M.,30-Mar-04 7:27 
QuestionDifference Please? Pin
Prakash Nadar30-Mar-04 1:02
Prakash Nadar30-Mar-04 1:02 
AnswerRe: Difference Please? Pin
Monty230-Mar-04 1:22
Monty230-Mar-04 1:22 
AnswerRe: Difference Please? Pin
22491730-Mar-04 1:27
22491730-Mar-04 1:27 
GeneralRe: Difference Please? Pin
Prakash Nadar30-Mar-04 2:27
Prakash Nadar30-Mar-04 2:27 
GeneralRe: Difference Please? Pin
David Crow30-Mar-04 3:50
David Crow30-Mar-04 3:50 
GeneralRe: Difference Please? Pin
Roger Wright30-Mar-04 4:24
professionalRoger Wright30-Mar-04 4:24 
GeneralRe: Difference Please? Pin
Ravi Bhavnani30-Mar-04 4:55
professionalRavi Bhavnani30-Mar-04 4:55 
GeneralRe: Difference Please? Pin
Roger Wright30-Mar-04 5:07
professionalRoger Wright30-Mar-04 5:07 
GeneralStrange .. Pin
Monty230-Mar-04 1:02
Monty230-Mar-04 1:02 
GeneralRe: Strange .. Pin
jhwurmbach30-Mar-04 1:46
jhwurmbach30-Mar-04 1:46 

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.