Android Question strange problem duplicating information

apti

Member
I have been getting a very strange issue. on the test device used to develop everything is fine. however all the other devices using the software are seeing this issue.

I have a listbox that is getting duplicate information. It fills up twice with the same info. below is the code. Maybe I am missing something but even if this sub is executed twice or 100 times it should only have one copy of information in it because I clear the list first. What is it I am missing? the information is the list is repeated so item 1,2,3,4 followed again by 1,2,3,4 not listed as 1,1,2,2,3,3,4,4.

Sub PopulateShortcut(crap As String)As ResumableSub
Dim R As String
Dim DBIP As String= INI.ReadString("DBINFO","DBAddress","") <--------------------- database stuff
Dim DBPort As String=INI.ReadString("DBINFO","DBPort","") <--------------------- database stuff
Dim DBUser As String=INI.ReadString("DBINFO","DBUser","") <--------------------- database stuff
Dim DBPassword As String=Func.DescrambleAugment(INI.ReadString("DBINFO","DBPassword",""),7,4) <--------------------- database stuff

lstshortcut.Clear <---------- clears list
HMShortCut=0 <------ just a counter for debugging

If OkToPopulateShortcut Then <----------- checks if a special condition is set. if so then list left blank
wait for (SQ.GetData(DBIP,DBPort,"LCARS",LCARS1.D_Shortcut,DBUser,DBPassword,"ComName",1,"uName = '"&SysUser&"' ORDER By ComName")) complete(R As String) <--- gets info
Do While R<>""
lstshortcut.AddSingleLine(Func.GetFieldByPlace(R,Func.cRecordDelimter,1)) <----- gets first record in the results
R=Func.DropFirstField(R,Func.cRecordDelimter) <---------- removes first record from results
HMShortCut=HMShortCut+1
Loop
End If
Return crap
End Sub
 
Solution
well I figured it out myself after much reading.

So for those that need the help....
it seems that resumable sub operate using some kind of magic. I ended up creating a global variable that is checked when entering the sub. If the variable is set then the sub just exits. The variable is set in the beginning of the sub. Then turned off in the end so the sub only executes once at a time. Also make sure you are calling the resumable sub with wait for and that seems to have fixed the issue. Seems that async can make a mess of a normally good program. But once you know the issue you can keep it controlled.

apti

Member
I am still trying to figure this out. I have found that the subroutine is not finishing. It is like the sq.getdata is exiting and control is not returning to this sub. Is that possible? and if it is why and how?
 
Upvote 0

apti

Member
well I figured it out myself after much reading.

So for those that need the help....
it seems that resumable sub operate using some kind of magic. I ended up creating a global variable that is checked when entering the sub. If the variable is set then the sub just exits. The variable is set in the beginning of the sub. Then turned off in the end so the sub only executes once at a time. Also make sure you are calling the resumable sub with wait for and that seems to have fixed the issue. Seems that async can make a mess of a normally good program. But once you know the issue you can keep it controlled.
 
Upvote 0
Solution
Top