How to 'multithread' ServerXMLHTTP in FoxPro 7?  
Author Message
SJH22





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

So, Ive got a dilema and maybe some of you can help me. Im using ServerXMLHTTP as an object to download about 500,000 web pages and I need to figure out how to run multiple instances of XMLHTTP.

For simplicity sake, this is what I have right now:

objXMLGET = CREATEOBJECT('MSXML2.serverXMLHTTP')

FOR x = 1 TO 500000

ThePage = "http://webpage id=" + STR(x)
objXMLGET.Open ("GET", ThePage , "False")
objXMLGET.Send
sResults = objXMLGET.ResponseBody

** parse routine here **

NEXT x

The problem is that I have so many web pages to go thru, it will take days to accomplish this. Is there anyway I can change the async to True and run more than one instance of the XMLHTTP

Thanks in advance,

SJH



Visual FoxPro1  
 
 
chanmy8





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

Hi,
Please check this if these links help.

http://blogs.msdn.com/calvin_hsia/archive/2006/05/11/595562.aspx
http://blogs.msdn.com/calvin_hsia/archive/2006/05/16/599108.aspx
http://blogs.msdn.com/calvin_hsia/archive/2006/05/23/605465.aspx
http://www.craigbailey.net/articles/VFPBusinessSkills/index.htm page=_1R517NQ76.htm

 
 
SJH22





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

Thanks for then info...unfortunately I did specify that I was using FoxPro 7 and these programs appear to be using the command 'TRY' which didnt get developed until VFP 8. Im currently using 7 exclusively and would really hate to retrofit all my programs so If anyone here know of a multi-threading example using 7, I would greatly appreciate it.

Thx,

S


 
 
SC_A9





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

One thing you might want to do is cut your application to minimal "get" functionality, and create it as a seperate executable, which writes its output to a (locally shared) table. Then you can let the OS worry about threading/multitasking. Your error handling task might be a little easier as well, since any serious problem with fetching data would be limited to a single mini-exe instance.


 
 
AndyKr





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

>>these programs appear to be using the command 'TRY' which didnt get developed until VFP 8.

PMFJI but TRY...CATCH...ENTRY is merely an error handler (more accurately, an Exception handler). You could re-write Calvin's code without using it and simply handle errors directly. The code between the TRY and the CATCH statements is what matters.




 
 
Claude Fox





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

Check out http://www.codeplex.com/mtmyvfp - I rewrote all the "vfp 9 only" routines to work with VFP 7,8, and 9 ...

 
 
Claude Fox





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

Also, unless you're actually using the XML features, you might want to just use WinHTTPRequest instead for more efficient processing. ServerXMLHTTP is based on this object.

 
 
CChalom





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

Hi Claude,

I've been using your MultiThread classes for 6 months, with great success. They really offer a great possiblility, and easy to implement.

Thanks very much !

Cesar


 
 
Claude Fox





PostPosted: Visual FoxPro General, How to 'multithread' ServerXMLHTTP in FoxPro 7? Top

Great! The real thanks goes to Calvin Hsia. IMO, this is the best addition to VFP in quite a while. I just tried to make it easier for everyone to use with my examples on Codeplex.