Webrequest.Timeout for asynchronous calls?

N1c0_ds

Active Member
Licensed User
I'm trying to set a timeout for my HTTP request while using an async call (getasyncresponse). However I noticed Timeout doesn't work for async calls.
 
Last edited:

N1c0_ds

Active Member
Licensed User
But it's used to download screenshots, files and information. I must be able to do something when there's no connection (put a filler screenshot image, stop the download and show an error message).

I really need to have a timeout. Maybe using timers? :sign0085: Is there any way to stop a response call? I would stop the call after 5 seconds using a timer's tick event.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Somthing like:
B4X:
Sub Globals
   ignoreResponse = false
End Sub

Sub App_Start
     Form1.Show
     request.New1(URL)
     response.New1
     request.GetAsyncResponse
      ignoreResponse = false
      Timer1.Enabled = true 'interval = 30000

End Sub

Sub Timer1_Tick
 Timer1.Enabled = false
 ignoreRequest = true
 msgbox("Error connecting to site.")
End Sub


Sub request_Response
 if ignoreRequest then return
 ...
End Sub
 
Top