Sub Process_Globals
Private fx As JFX
Private MainForm As Form
'I create a map that holds the status of the queries:
Private QueriesStatus As Map = CreateMap("Query1": False, "Query2": False, "Query3": False)
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
MainForm.Show
StartQueries
End Sub
Sub StartQueries
Dim sq As SQL
'Job 1
sq.ExecQueryAsync("Query1", "SELECT * FROM customers;", Null)
'Job 2
sq.ExecQueryAsync("Query2", "SELECT * FROM countries;", Null)
'Job 3
sq.ExecQueryAsync("Query3", "SELECT * FROM planets;", Null)
End Sub
Sub Query1_QueryComplete (Success As Boolean, Crsr As ResultSet)
If Success Then
'Do my thing with this query
'...
'Save the status as true (finished):
QueriesStatus.Put("Query1", True)
'Then check the status of the other queries:
CheckStatus
End If
sq.close
End Sub
Sub Query2_QueryComplete (Success As Boolean, Crsr As ResultSet)
If Success Then
'... something
QueriesStatus.Put("Query2", True)
CheckStatus
End If
sq.close
End Sub
Sub Query3_QueryComplete (Success As Boolean, Crsr As ResultSet)
If Success Then
'... something
QueriesStatus.Put("Query3", True)
CheckStatus
End If
sq.close
End Sub
Sub CheckStatus
If QueriesStatus.Get("Query1") = True AND _
QueriesStatus.Get("Query2") = True AND _
QueriesStatus.Get("Query3") = True Then
'All the queries are finished.
'...
End If
End Sub