doevents

Lutz99999

New Member
Licensed User
Longtime User
Hello

i use async stream and the New_data event.
in my main i must wait for the response from the network.
And the AStreams_NewData event is not fired
what can i do ?

code :

dim weiter as boolean

Sub AStreams_NewData (Buffer() As Byte)
weiter = true
end sub

Sub Send (what As String)

do until weiter = true
doevents
loop

end sub

greetings Lutz
 

derez

Expert
Licensed User
Longtime User
The NewData sub will run when data arrives, so you don't have to wait for it elsewhere, especially not in a loop:
B4X:
Sub AStreams_NewData (Buffer() As Byte)
'check what is in the buffer
send(what) 'or do whatever you need to
end sub
 
Upvote 0

Lutz99999

New Member
Licensed User
Longtime User
I understand what is the problem.
when i finish the loop the event will be fired.
can i manuell force the event


do until weiter = true
doevents
force the fire event
loop
 
Upvote 0

derez

Expert
Licensed User
Longtime User
I understand what is the problem.
Well, I don't.
I think your problem is that the newData event is not fired and you do want it to fire, but the cause for this is in your connection or data transfer.
The idea of Astream is that it knows when there is data ready and then the event is launched. You can run the sub manually but in that case you don't have the data ready and that is not a good idea.
The loop is not necessary !
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Derez is absolutely right.
If you need that your server sends some sort of 'welcome' message, then this would be there in your aStreams_newData.
But... what is the response you are waiting for? How are you connecting to your server?
 
Upvote 0
Top