Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X


Send WinHTTP Request but don't wait for response?

  • Please log in to reply
2 replies to this topic

#1 Gui



  • Active Members
  • PipPipPip
  • 171 posts

Posted 21 June 2012 - 12:21 AM

So technically, to send a WinHTTP request, you have..:
$h_openRequest = _WinHttpOpenRequest($hw_connect, "GET", "/" , "HTTP/1.1", "") _WinHttpSendRequest($h_openRequest) _WinHttpReceiveResponse($h_openRequest) $data = '' Do $data &= _WinHttpReadData($h_openRequest) Until @error

Typically, some responses may take a few seconds to load, and thus slows your script. Is there a way to send the request but not wait for the load? In other words, instead leave it to load on its own and move on with the script? Thanks!


#2 Gui



  • Active Members
  • PipPipPip
  • 171 posts

Posted 23 June 2012 - 02:42 PM


#3 Robjong



  • Active Members
  • PipPipPipPipPipPip
  • 318 posts

Posted 23 June 2012 - 02:50 PM

This is one way to do it:
ConsoleWrite("Script started" & @LF) AdlibRegister("foo") ; register the adlib function, this does not hold up the script ConsoleWrite("Script continues while the function is busy" & @LF) Sleep(4000) ; keep the script from terminating for a while ConsoleWrite("Script ended" & @LF) Func foo()     AdlibUnRegister("foo") ; unregister the function to avoid it being called again     ; winhttp etc. here...     Sleep(1000) ; simulate waiting for a response     ConsoleWrite("I did not hold up the script :)" & @LF) EndFunc

Edited by Robjong, 23 June 2012 - 02:53 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users