I’m using a slightly modified OkHttpUtils. (It’s modified to be more specialized when communicating with the API on my server.)
In it there's an event _ResponseSuccess that contains this:
The GetAsynchronously causes an event to the sub below, just as we’re used to:
For a couple of different reasons I wanted to update and modernize this to use Wait For instead, like so:
But that didn’t work at all. It crashes with this error message:
So even though I’m using Wait For, it doesn’t ”catch” the event. Am I doing something wrong here, or what’s going on?
In it there's an event _ResponseSuccess that contains this:
B4X:
' Response is an OkHttpResponse
Response.GetAsynchronously("response", File.OpenOutput(temp_folder, theJobId, False), True, theJobId)
The GetAsynchronously causes an event to the sub below, just as we’re used to:
B4X:
Private Sub Response_StreamFinish (Success As Boolean, theJobId As Int)
DoThings
End Sub
For a couple of different reasons I wanted to update and modernize this to use Wait For instead, like so:
B4X:
' Response is an OkHttpResponse
Wait For (Response.GetAsynchronously("", File.OpenOutput(temp_folder, theJobId, False), True, theJobId)) StreamFinish (Success As Boolean, theJobId As Int)
DoThings
But that didn’t work at all. It crashes with this error message:
B4X:
java.lang.RuntimeException: java.lang.Exception: Sub _streamfinish was not found.
So even though I’m using Wait For, it doesn’t ”catch” the event. Am I doing something wrong here, or what’s going on?