In a class I have this:
And I call this from Main like this:
Problem is it doesn't wait for the first cEvents.ShowMsg and I see the second Msgbox2Async first and
the first cEvents.ShowMsg only later. Tried various constructions, eg with Sleep(0), but no success yet.
How should this be done?
RBS
B4X:
Sub ShowMsg(strPrompt As String, _
strTitle As String, _
iTitleColour As Int, _
iPromptColour As Int, _
csPrompt As CSBuilder, _
bmpIcon As Bitmap, _
bCancelable As Boolean, _
bWait As Boolean)
Dim csTitle As CSBuilder
'so like optional colour argument
If iTitleColour = 0 Then
iTitleColour = Colors.RGB(0, 0, 0)
End If
If iPromptColour = 0 Then
iPromptColour = Colors.RGB(0, 0, 0)
End If
csTitle.Initialize.Color(iTitleColour).Append(strTitle).Pop
'so csPrompt is like an optional argument, passing Null works fine
If csPrompt.IsInitialized = False Then
csPrompt.Initialize.Color(iPromptColour).Append(strPrompt).Pop
End If
'can pass Null for no icon
Msgbox2Async(csPrompt, csTitle, "OK", "", "", bmpIcon, bCancelable)
If bWait Then
Wait For Msgbox_Result(iResult As Int)
End If
End Sub
And I call this from Main like this:
B4X:
Sub DeleteDuplicateSQL
Dim strSQL As String
Dim lAffectedRows As Long
Msgbox2Async("Are you sure to delete duplicate SQL from the table SQL?", _
"Delete duplicate SQL from table SQL", "Yes", "No", "", General.bmpIcon32, False)
Wait For Msgbox_Result(result As Int)
If result = -1 Then
strSQL = "DELETE FROM SQL WHERE ROWID NOT IN(" & _
"SELECT MAX(ROWID) FROM SQL " & _
"GROUP BY SQL)"
General.SQL1.ExecNonQuery(strSQL)
lAffectedRows = GetNumberOfChanges
cEvents.ShowMsg("Duplicate rows deleted: " & lAffectedRows, _
"Delete duplicate SQL from table SQL", 0, 0, Null, General.bmpIcon32, True, True)
End If
Msgbox2Async("Are you sure to delete duplicate SQL from the table RUN_SQL?", _
"Delete duplicate SQL from table RUN_SQL", "Yes", "No", "", General.bmpIcon32, False)
Wait For Msgbox_Result(result As Int)
If result = -1 Then
strSQL = "DELETE FROM RUN_SQL WHERE ROWID NOT IN(" & _
"SELECT MAX(ROWID) FROM RUN_SQL " & _
"GROUP BY SQL)"
General.SQL1.ExecNonQuery(strSQL)
lAffectedRows = GetNumberOfChanges
cEvents.ShowMsg("Duplicate rows deleted: " & lAffectedRows, _
"Delete duplicate SQL from table RUN_SQL", 0, 0, Null, General.bmpIcon32, True, True)
End If
End Sub
Problem is it doesn't wait for the first cEvents.ShowMsg and I see the second Msgbox2Async first and
the first cEvents.ShowMsg only later. Tried various constructions, eg with Sleep(0), but no success yet.
How should this be done?
RBS