Hello to all !!
How can I wait a second inside an Event ??
Ok ok, I explain better.
I have an HttpServer and with HandleRequest event I accept a GET request and I need to answer, but first I need to wait 1 second.
Here is the source that works correctly:
But, as all the world knows, "DoEvents" is deprecated, but if I change to
it don't works, because when the code execute Sleep line, it exit from the event, and Response.SendString don't work
How to solve it ??
Thanks
How can I wait a second inside an Event ??
Ok ok, I explain better.
I have an HttpServer and with HandleRequest event I accept a GET request and I need to answer, but first I need to wait 1 second.
Here is the source that works correctly:
B4X:
Sub Server_HandleRequest(Request As ServletRequest, Response As ServletResponse)
' Wait one second
Dim Adesso As Long = DateTime.Now + DateTime.TicksPerSecond ' aspetta un secondo
Do Until DateTime.Now >= Adesso
DoEvents
Loop
' send the response
Response.SetContentType("text/html")
Response.SendString("Perfect, all right !")
End Sub
But, as all the world knows, "DoEvents" is deprecated, but if I change to
B4X:
Sub Server_HandleRequest(Request As ServletRequest, Response As ServletResponse)
' Wait one second
Sleep(1000)
' send the response
Response.SetContentType("text/html")
Response.SendString("Perfect, all right !")
End Sub
How to solve it ??
Thanks
Last edited: