Jump to content

Send WinHTTP Request but don't wait for response?


 Share

Recommended Posts

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!

GUI

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...