Android Question thread and progressbar

ivanomonti

Expert
Licensed User
Longtime User
why does the progressbar always appear after the code is executed, ie when it comes back to hide?


B4X:
Sub DeleteRecord
   
    If itemSelect.IsInitialized = False Then
        Msgbox("Nessuna scheda è stata selezionata","Attenzione")
        Return
    End If
   
    If Msgbox2("Sicuro di voler eliminare questo cliente?","Attenzione","Si","","No",Null) <> -1 Then
        Return
    End If
   
    Dim th As Thread
    th.Initialise("th")
    th.Sleep(1000)
    If th.RunOnGuiThread("progressShow",Null) = True Then
        Dim sqlite As IMSQLite
        Private query As String
        sqlite.Initialize
        query = "DELETE FROM clienti WHERE ID = " & itemSelect.Get(0)
       
        If sqlite.delete_db_cliente(query) = True Then
           
            Dim lt,tt,wt,ht As Float
            Dim count As Int
           
            ' remove row
            For i = 0 To panel4.Panel.NumberOfViews-1

                If panel4.Panel.GetView(i) Is Panel Then
                    Dim frame As Panel = panel4.Panel.GetView(i)
                    Dim ls As List = frame.Tag
                    If ls.Get(0) = itemSelect.Get(0) Then
                        lt = panel4.Panel.GetView(i).Left
                        tt = panel4.Panel.GetView(i).Top
                        wt = panel4.Panel.GetView(i).Width
                        ht = panel4.Panel.GetView(i).Height
                        count = i
                        frame.RemoveView
                    End If
                End If
            Next
            ' riordina row
            For i = count To panel4.Panel.NumberOfViews-1
                panel4.Panel.GetView(i).Left = lt
                panel4.Panel.GetView(i).Top = tt
                panel4.Panel.GetView(i).Width = wt
                panel4.Panel.GetView(i).Height = ht
                tt = tt + ht
                panel4.Panel.Height = tt
            Next
        End If
    End If
   
   
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…