B4J Question HttpJob in BackGroundWorker compared to PyBridge server example. Benchmark. Is it correct?

hatzisn

Expert
Licensed User
Longtime User
Good evening to all of you,

I was exploring the PyBridge server example and I was wondering If we do the same with an HttpJob in the worker class then what happens in the background worker class. Is the worker thread considered busy until it returns the answer in order to serve an other handler's function calling? I checked this out with multiple requests and it seems that it remains busy in the same thread until it finishes the httpjob and return the value. I do not know if my methodology is correct and I am not a hundred percent sure if what I have observed is correct. I am writting bellow the code of the multiple requests console app and I attach the benchmarking application. What confuses me is the order of the job results in relation to the datetime now they were initiated and returned - it is an ID of course of order... Is this correct?

(Start the "Check1Thread" in debug mode to emulate latency and the code bellow in release mode. Then compare it to what happens if we start both in release mode. What is wrong in this case?????? Does it show that it does not work as expected?)

B4X:
Sub Process_Globals
    Dim iCounter As Int = 0
End Sub

Sub AppStart (Args() As String)
    Log("Making Multiple Requests!!!")
    MakeMultipleRequests
    StartMessageLoop
End Sub

Sub MakeMultipleRequests
    For ii = 1 To 50
        Dim hj As HttpJob
        hj.Initialize("jb" & ii, Me)
        hj.Download("http://localhost:51042/checkone")
    Next
End Sub

Sub JobDone(hj As HttpJob)
    iCounter = iCounter + 1
    Log(iCounter & "--" & hj.JobName & "==" &  hj.GetString)
    If iCounter = 50 Then
        StopMessageLoop
    End If
End Sub
 

Attachments

  • Check1Thread.zip
    3.5 KB · Views: 1
Top