B4J Question Equivalent of DoEvents?

wdegler

Active Member
Licensed User
Longtime User
When I set a breakpoint to stop at a line where I can see the (graphical) result, it usually does not show. Many more instructions must be executed before it does. In B4A, I could use DoEvents to solve this problem. How can I do it in B4J?
 

wdegler

Active Member
Licensed User
Longtime User
There is no equivalent method in B4J. Usually there are other ways to implement the task that do not block the main thread for a long time.

What is your code doing?
For example, in displaying a label, if a set a breakpoint in the statement following setting the text in a label, the text does not yet show when the breakpoint is reached. Example:

PrgLbl.Visible=True
PrgLbl.BringToFront
PrgLbl.Text="Setting properties..."
'DoEvents
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Hi there...
i want doevents too.. or something like threads...

I have an app that loads 100 map markers point that changing every 0.5 sec (vehicles)... and loops for ever... <yes i want that...

what can i do?... a simple example will help me..
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
That's i am doing now.. but into timer there are many calculations, such distance calculation, add to sql database as new record, and other... so 0.5 second will not be enough / so must run in same time (... other thread or something?)
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Actually i am moving code from vb6 to b4j...

but in vb6 was using doevents... like solution...

now i am making timer_tick code... will be like this (for the moment) - some code made in b4a (for other reasons / so as you can i am on moving):

B4X:
Sub JobDone (job As HttpJob)
   If job.Success = True Then
      Select job.JobName
         Case "Job8"          
            'Dim Markers As List
            t=job8.GetString2("GREEK").trim
           
            If t.IndexOf("PASTA")>-1 Then
                'ToastMessageShow("no admin", True)
                Log("oux")
                ExitApplication
            Else
           
            If fs=False Then
            'MapPane1.RemoveMapMarker(Marker1)
                Else
            'MarkersOverlay1.Initialize(MapView1, "MarkersOverlay1")
              'MarkersOverlay1.Initialize("Icon", Icon, 41.08805, 23.549323)
            'MarkersOverlay1.SetCursor(fx.Cursors.HAND)
            'MapView1.AddOverlay(MarkersOverlay1)
            'Log("ok")
            'MapPane1.AddMapOverlay(MarkersOverlay1)
            End If
           
           
            'Markers.Initialize

'here i am parsing... the vehicles alive...
           
            Dim car As String, llat As String, llng As String, lspeed As String, lmsg As String
            Dim lllat As Float, lllng As Float, lllspeed As Float
            Dim hx As Long, gx As Long, wp As Long
            hx=0
            gx = 1
            wp = 0
            Do While hx<t.Length
                If gx<=5  Then
                    Select Case gx
                        Case 1
                            wp=wp+1
                            car = t.SubString2(hx,t.IndexOf2("|",hx)).trim
                            hx = t.IndexOf2("|",hx)+1
                        Case 2
                            llat = t.SubString2(hx,t.IndexOf2("|",hx)).trim
                            hx = t.IndexOf2("|",hx)+1
                        Case 3
                            llng= t.SubString2(hx,t.IndexOf2("|",hx)).trim
                            hx = t.IndexOf2("|",hx)+1
                        Case 4
                            lspeed= t.SubString2(hx,t.IndexOf2("|",hx)).trim
                            hx = t.IndexOf2("|",hx)+1
                        Case 5
                            lmsg = t.SubString2(hx, t.IndexOf2("/",hx)).trim
                            gx = 0
                            hx=t.IndexOf2("/",hx)+1
                           
                            lllat = llat.Replace(",",".")
                            lllng = llng.Replace(",",".")
                            lllspeed = lspeed.Replace(",",".")
                           
                            If lllat > 0 AND lllng > 0  Then
                            If seecar.Trim="" Then
                            speed=lllspeed
                            Else
                            speed = lllspeed * 3.6
                            'MapView1.AnimateTo (lllat, lllng)
                            End If
                            xspeed = speed
                            thecar = car.trim
                           
                           
                               If lmsg.trim = "SOS" Then
                           
                               
                                If Marker1(thecar).IsInitialized=False Then
                                Marker1(thecar).Initialize2("car" , Icon2, lllat, lllng,0)
                                Marker1(thecar).SetCursor(fx.Cursors.HAND)
                                Marker1(thecar).Tag = "No." & car.trim & " - speed: " &  xspeed & "χλμ/ω"
                                MapPane1.AddMapMarker(Marker1(thecar))
                                Else
                                Marker1(thecar).Tag = "No." & car.trim & " - speed: " &  xspeed & "χλμ/ω"
                                Marker1(thecar).SetLat(lllat)
                                Marker1(thecar).setlon(lllng)
                                MapPane1.AddMapMarker(Marker1(thecar))
                                End If
                            Else
                                If Marker1(thecar).IsInitialized=False Then
                                Marker1(thecar).Initialize2("car" , Icon, lllat, lllng,0)
                                Marker1(thecar).SetCursor(fx.Cursors.HAND)
                                Marker1(thecar).Tag = "No." & car.trim & " - speed: " &  xspeed & "χλμ/ω"
                                MapPane1.AddMapMarker(Marker1(thecar))
                                Else
                                Marker1(thecar).Tag = "No." & car.trim & " - speed: " &  xspeed & "χλμ/ω"
                                Marker1(thecar).SetLat(lllat)
                                Marker1(thecar).setlon(lllng)
                                MapPane1.AddMapMarker(Marker1(thecar))
                                End If
                            End If
                            'Markers.Add(Marker1)

'here i ll ve the calculation of distance... with the previous point (lat,lon)

'+here i ll have the sql add new record + some other features / will have asyncronous i will helped...

                            End If
                    End Select
                gx=gx+1
                End If

'here i was hoping for doevents
           
            Loop

'here i was hoping for doevents + here making more light...

            'MapPane1.AddMapMarker(Marker1)
            'MarkersOverlay1.AddMarkers(Markers)
                       
            If fs Then
                  'TileSource="Mapnik"
                  'MapPane1.SetDisplayToFitMapMarkers'FitMapToBoundingBox(MarkersOverlay1.GetBoundingBox)
                  fs=False
                    'MapPane1.SetZoom(ZoomLevel)
                  'MapPane1.SetDisplayPosition(41.086662,23.547206,ZoomLevel)
                Else
                'MapView1.FitMapToBoundingBox(MarkersOverlay1.GetBoundingBox)
                'MapPane1.SetDisplayToFitMapMarkers
                'MapPane1.SetZoom(ZoomLevel)
                'MapView1.Zoom=ZoomLevel
            End If       
           
            End If
      End Select
   End If
   job.Release
   timer3.Enabled = True
End Sub

Sub download
'this  will replaced because i want to have it from local sql / will be better if read from SQL directly - here i am parsing it... for remote monitoring..
  job8.Initialize("Job8", Me)
  job8.download("http://" & serversite & "/livecheckall.asp?car=" & username & "&password=" & pass) 
end sub

Sub Timer3_Tick
timer3.Enabled = False
download
End Sub
 
Upvote 0
Top