Will it be possible to implement timeout?
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1")
gmap.Initialize2("gmap", Null, "xxxxxxxxYNLkvBkQ2LhGujrM")
Pane1.AddNode(gmap.AsPane, 0, 0, Pane1.Width, Pane1.Height)
MainForm.Show
Wait For Gmap_Ready '<----------------
btnResetMap.Enabled = True
btnJumpToEiffel.Enabled = True
For i = 1 To 10
gmap.AddMarker(10 * i, 10 * i, "Marker #" & i)
Next
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1")
MainForm.Show
SetImage(ImageView1, "https://cdn.pixabay.com/photo/2016/09/04/08/46/butterfly-1643510_960_720.jpg")
SetImage(ImageView2, "https://cdn.pixabay.com/photo/2017/03/29/07/29/windmill-2184353__340.jpg")
SetImage(ImageView3, "https://cdn.pix3abay.com/photo/2017/04/02/09/08/bulldozer-2195329__340.jpg")
End Sub
Sub SetImage(iv As ImageView, link As String)
'show a progress indicator while downloading
Dim pb As ProgressIndicator
pb.Initialize("")
Dim parent As Pane = iv.Parent
parent.AddNode(pb, iv.Left, iv.Top, iv.Width, iv.Height)
pb.Progress = -1
Dim j As HttpJob
j.Initialize("j", Me)
j.Download(link)
'wait for JobDone event
Wait For (j) JobDone(j As HttpJob)
'Remove the progress indicator
pb.RemoveNodeFromParent
If j.Success Then
iv.SetImage(j.GetBitmap)
Else
Log(j.ErrorMessage)
iv.SetImage(fx.LoadImage(File.DirAssets, "Sorry-image-not-available.png"))
End If
End Sub
Sub MakeSeveralDownloadsSequentially
Dim j As HttpJob
j.Initialize("j", Me)
j.Download("https://cdn.pixabay.com/photo/2016/09/04/08/46/butterfly-1643510_960_720.jpg")
Wait For JobDone(j As HttpJob)
If j.Success Then
Log("First image downloaded successfully")
End If
j.Release
j.Initialize("j", Me)
j.Download("https://cdn.pixabay.com/photo/2017/03/29/07/29/windmill-2184353__340.jpg")
Wait For JobDone(j As HttpJob)
If j.Success Then
Log("Second image downloaded successfully")
End If
j.Release
j.Initialize("j", Me)
j.Download("https://cdn.pixabay.com/photo/2017/04/02/09/08/bulldozer-2195329__340.jpg")
Wait For JobDone(j As HttpJob)
If j.Success Then
Log("Third image downloaded successfully")
End If
j.Release
End Sub
Sub Rec (i as int, lim as int)
if i < lim then
dosomething
callsubdelayed3(me,"rec",i+1,50)
end if
end sub
Sub Rec
For i = 1 to 1000
DoSomething
Sleep(0)
'Or sleep every 10 iterations
If i Mod 10 = 0 Then
Sleep(0)
End If
Next
End Sub
Socket.connect(IP,Port,0)
Sleep(4000)
If socket.connected = False Then
log("failed to connect")
else
log("connected OK")
End if
Yes, but it is better to use Wait For in this case:Does this mean I can do something like:
Socket.Connect(IP, Port, 4000)
Wait For Socket_Connected (Success As Boolean)
If Success Then
...
Else
...
End If
It will probably be available in B4A and B4i in June or July.what about B4A & B4i.. Any ETA when it will be added to them as well providing it is successful in B4J in May/June ?
'non-ui project!!!
Sub AppStart (Args() As String)
DoSomething
StartMessageLoop
Log("done!")
End Sub
Sub DoSomething
For i = 1 To 10
Log(i)
Sleep(100)
Next
StopMessageLoop
End Sub
'non-ui project!!!
Sub AppStart (Args() As String)
For i = 1 To 10
Log(i)
Sleep(100)
Next
StartMessageLoop
Log("done!")
End Sub
StartMessageLoop
https://www.b4x.com/android/forum/threads/non-ui-applications.34657/#contentWhat is the purpose of StartMessageLoop and StopMessageLoop?
I think but my two neurons do notLuca you need to think again...
Quiz:
What is the output of this code:
B4X:'non-ui project!!! Sub AppStart (Args() As String) DoSomething StartMessageLoop Log("done!") End Sub Sub DoSomething For i = 1 To 10 Log(i) Sleep(100) Next StopMessageLoop End Sub
And this one:
B4X:'non-ui project!!! Sub AppStart (Args() As String) For i = 1 To 10 Log(i) Sleep(100) Next StartMessageLoop Log("done!") End Sub
Tip: Sleep ≈ Return
I'm trying right now (2 am!)Luca you need to think again
'non-ui project!!!
Sub AppStart (Args() As String)
DoSomething
StartMessageLoop
Log("done!")
End Sub
Sub DoSomething
For i = 1 To 10
Log(i)
Sleep(100)
Next
StopMessageLoop
End Sub
'non-ui project!!!
Sub AppStart (Args() As String)
For i = 1 To 10
Log(i)
Sleep(100)
Next
StartMessageLoop
Log("done!")
End Sub
Sub InternalAppStart
AppStart(...)
StartMessageLoop
End Sub
- Code after StartMessageLoop will only be executed after StopMessageLoop is called.
... and since I thought this, I wanted tried and it seems that it is not so: a log was executed after StartMessageLoop, I did not wrote StopMessageLoop and I did not stop the serverI thought that this was to be the last statement of AppStart routine, ie that subsequent instructions were not be executed (or at least only after a StopMessageLoop);
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?