Android Question progressdialogshow disappears prematurely

vbmundo

Well-Known Member
Licensed User
Hi,

I start the ProgressDialogShow in a SUB, and run the ProgressDialogHide in another SUB.

The problem is that this ProgressDialogShow disappears before run the ProgressDialogHide.

I have this code

B4X:
Sub SELECT_update(r As Map)
    Dim Campos(r.Size) As String, i As Int 
    Registros=Registros+1
    ProgressDialogShow(Registros & " rows processed")
    If PrimerRegistro=1 Then
        Dim Cabeceras(r.Size) As String
        PrimerRegistro=0
        g.Initialize(Me,"g")
        g.InitializeTable(r.size,0,False)
        g.AddToActivity(Activity , 0, 50dip, 100%x, 80%y)
        For i = 0 To r.Size-1
            Cabeceras(i)=r.GetKeyAt(i)   
        Next
        g.SetHeader(Cabeceras)
    End If
    For i = 0 To r.Size-1
        Campos(i)=r.GetValueAt(i)
    Next
    G.AddRowAutomaticWidth(Campos)
End Sub

Sub SELECT_complete(Status As Boolean)
    ProgressDialogHide
    lblCantRegistros.Text=Registros & " Rows "
End Sub

Sub SELECT_error(ErrDesc As String)
    Msgbox("Error : " & ErrDesc,"Error")
End Sub

This is not the unique code where I have problem.. it's only one of

The process start in SELECT_update and ends in SELECT_complete but the ProgressDialogShow disappears suddenly

What's wrong ?
 

ilan

Expert
Licensed User
Longtime User
Try to put DoEvents after you show the progressdialog.

B4X:
ProgressDialogShow(Registros & " rows processed")
DoEvents
'....
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
You can also start showing the progressbardialog in the sub you call the "updatesub" and you may also call the "updatesub" with callsubdelayed()

EDIT: (something like this)

B4X:
Sub btn_click
    ProgressDialogShow(Registros & " rows processed")
    CallSubDelayed2(Me,"SELECT_update",mymap)
End Sub

Sub SELECT_update(r As Map)
    Dim Campos(r.Size) As String, i As Int
    Registros=Registros+1
    If PrimerRegistro=1 Then
        Dim Cabeceras(r.Size) As String
        PrimerRegistro=0
        g.Initialize(Me,"g")
        g.InitializeTable(r.size,0,False)
        g.AddToActivity(Activity , 0, 50dip, 100%x, 80%y)
        For i = 0 To r.Size-1
            Cabeceras(i)=r.GetKeyAt(i)  
        Next
        g.SetHeader(Cabeceras)
    End If
    For i = 0 To r.Size-1
        Campos(i)=r.GetValueAt(i)
    Next
    G.AddRowAutomaticWidth(Campos)
End Sub
 
Last edited:
Upvote 0
Top