I have the below recursive routine.
There is over 20,000 directories / files that this is doing, it hangs the UI while doing it.
How do I write this recursive routine as something I can wait on that will allow the UI to work smoothly
There is over 20,000 directories / files that this is doing, it hangs the UI while doing it.
How do I write this recursive routine as something I can wait on that will allow the UI to work smoothly
B4X:
Sub Process_Globals
Private fx As JFX
Private mFileTools As FileTools
end Sub
Public Sub ListOfFiles(Directory As String, Files As List)
Dim FileList As List = mFileTools.ListFiles(Directory)
Dim DirList As List = mFileTools.ListDirs(Directory)
Dim TempFile As String
If FileList.IsInitialized And FileList.Size > 0 Then
For i = 0 To FileList.Size-1
TempFile = FileList.Get(i)
TempFile = TempFile.ToLowerCase
If TempFile.EndsWith(".mp3") Then
Files.Add(Directory &"\" &FileList.Get(i))
End If
Next
End If
If DirList.IsInitialized And DirList.Size > 0 Then
For i = 0 To DirList.Size-1
ListOfFiles(Directory &"\" &DirList.Get(i), Files)
Next
End If
Return
End Sub