i am trying to handle a huge requests within the server by sending data From each Client Class as a Queue
in the Client Class i have setup a Timer
and each Time the Timer Fired it should handle the list of commands to be sent as Following
But The astream.Write(Cmdstr) doesn't send data in loop i should call sleep() in the loop in order to make it send properly
any idea why i cannot send in loop without calling sleep() ?
is there any proper way to handle this better ?
any idea why ?
in the Client Class i have setup a Timer
B4X:
Dim SendTimerQueue As Timer
Dim ClientCMdList As List
Dim SendingQueue As Boolean
and each Time the Timer Fired it should handle the list of commands to be sent as Following
B4X:
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(socket As Socket, Serv As Tcserver)
ClientCMdList.Initialize
SendTimerQueue.Initialize("SendTimerQueue", 1000)
Aserver = Serv
astream.Initialize(Me, "AStream", socket.InputStream, socket.OutputStream)
End Sub
Sub SendTimerQueue_tick
If ClientCMdList.IsInitialized Then
If ClientCMdList.Size > 0 Then
If SendingQueue = True Then
Return
End If
SendingQueue = True
For i = ClientCMdList.Size -1 To 0 Step -1
Dim Cmdstr As String
Cmdstr = ClientCMdList.Get(i)
astream.Write(Cmdstr)
ClientCMdList.RemoveAt(i)
Next
SendingQueue = False
End If
End If
End Sub
But The astream.Write(Cmdstr) doesn't send data in loop i should call sleep() in the loop in order to make it send properly
B4X:
For i = ClientCMdList.Size -1 To 0 Step -1
Dim Cmdstr As String
Cmdstr = ClientCMdList.Get(i)
astream.Write(Cmdstr)
ClientCMdList.RemoveAt(i)
sleep(50)
Next
any idea why i cannot send in loop without calling sleep() ?
is there any proper way to handle this better ?
any idea why ?