B4J Question nested events

uniplan

Active Member
Licensed User
Longtime User
Dears,

is it possible to push the system to serve new events while running the code
called in serving a previous event ?

For example in the following code (non-UI application)


#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region

Sub Process_Globals
Dim Timer1Test, Timer2Test As Timer
End Sub


Sub AppStart (Args() As String)
Timer1Test.Initialize("Timer1",1000)
Timer2Test.Initialize("Timer2",2000)

Timer1Test.Enabled = True
Timer2Test.Enabled = True

StartMessageLoop
End Sub

Sub Timer2_Tick()
Dim a As Int = 1
Do While a > 0
a = a+1
Loop
End Sub

Sub Timer1_Tick()
Dim b As Int = 1
Do While b > 0
b = b+1
Loop
End Sub


the execution (obviously) remains stuck in the loop of Timer1_Tick.
Would it be possible to push the service of queued events while looping ?

Of course, it would be my charge the mangement of exclusive access
and all other multithread-like stuff.

Thanks.
 

uniplan

Active Member
Licensed User
Longtime User
Dear Erel,

of course there is no motivation in the example I wrote. It was just the template I used
in order to check the behavioral model about events.

Moreover, we already use StartMessageLoop at the end in AppStart after initializations.

My question was aimed at have two options : non-blocking / blocking in a class method.
For the case of blocking it would be necessary to wait for a timeout event or
a newdata-from-asyncstream event but, of course, such events cannot be dispatched
if previous event execution is stuck in a loop.

Hence, I asked if there could be something like DoNextMessage or Yeld, or whatever else.

Is it possible to poll for data on an asyncstream ?
 
Upvote 0
Top