o.HTTPGetExAsync(tcPage,tcResultFile,tnResultSize,tcHeaders)
tcResultFile
Path to a file that will be created with the output from the request.
tnResultSize
The size of the data to be written to the file. This is required, so be sure to specify a size that's large enough. You should be careful not to use too large of a buffer either because memory will be preallocated for this amount of data.
tcHeaders
HTTP Headers to set on the request.
tnSecondsBeforeDelete
Number of seconds for the file to stick around. The Async thread will stick around this long after creating the file and then delete it automatically.
If you will display the result file or otherwise persist the data it's recommended you copy it to a new location or a string and then delete the original.
If you quit Visual FoxPro while an async thread is active, VFP will crash!
CLEAR
DO WCONNECT
loIP = CREATEOBJECT("wwHTTP")
loIP.HTTPConnect("www.west-wind.com")
loIP.AddPostkey("FirstName","Rick")
loIP.AddPostkey("Company",TIME())
loIP.AddPostKey("LastName","STRAHL")
lcFile = SYS(2023) + "\AsyncTest.htm"
ERASE (lcFile)
loIP.HTTPGetExAsync("/wconnect/wc.dll?wwdemo~TestPage",;
lcFile,40000,"",10)
loIP.HTTPClose()
*** The following is a simulation of some check code
*** this could be done off a timer or some other processing
*** that took place instead of in this poll loop
lnSeconds = SECONDS()
*** Simulate checking for file
DO WHILE SECONDS() - lnSeconds < 15
lcResult = File2Var(lcFile)
? "Checking...",LEN(lcResult)
IF EMPTY(lcResult)
DOEVENTS
LOOP
ENDIF
*** We got our result - let's delete the file
*** to signal the thread we're done to kill the thread
ERASE (lcFile)
EXIT
ENDDO
*** Just display the result as HTML
SHOWHTML(lcResult)