My app freeze!?

ilan

Expert
Licensed User
Longtime User
hi

i creat a app with some calculation
some calculation can take a little bit long like 20-30 sec.
at this time my app freeze i cannot do anything
and i get also a massage box that tells me :"Sorry, app is not responding"
and i can choose between two buttons : WAIT, and FORCE CLOSE

if i click wait it works

what could i do? is thre maybe a backgroundworker where i can do the calculation without freezing the app?

thanx
 

manios

Active Member
Licensed User
Longtime User
Try to put a DoEvents statement into the calculation loop.
 
Upvote 0

manios

Active Member
Licensed User
Longtime User
From the docs:
DoEvents
Processes waiting messages in the messages queue.
DoEvents can be called inside lengthy loops to allow the program to update its UI. Other waiting events will not be handled by DoEvents.

Search for the keyword "doevents", you will get some more details.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i searchd for doevents but couldnot understand how it works

this is my code:

B4X:
  For i = 0 To menu.list1.Size - 1
                   For i2 = (i + 1) To menu.list1.Size - 1
                        For i3  = (i2 + 1) To menu.list1.Size - 1
                  
                         If menu.List2.get(i) + menu.List2.get(i2) + menu.List2.get(i3) = gimcount.Text Then  
               
                                list1.AddSingleLine(menu.List1.get(i) & " + " & menu.List1.get(i2) & " + " & menu.List1.get(i3))                     
                            
                           End If
                          
                     If list1.Size  = Spinner1.SelectedItem Then
                          found.Text = Spinner1.SelectedItem
                              loader.Visible = False
                              loader.Enabled = False
                                Exit
                           End If
                        Next
                   Next
                Next

where should i whrite DOEVENTS??

thanx
 
Upvote 0
Top