Hi,
I have a create a service module from a Sub in my main program. As my UI is using an animation to show the user that the app is working (similar to ProgressDialogShow) however as the sub is deleting a lot of files, in a folder, (100meg-2GB) This make the animation freeze for short periods. In a bid to make it look more professional. I would like a smooth animation. So its been suggested I use a service. I have never used a service myself and just want a little help rearranging the code!
This is the Sub
So I have created a service module "FolderRemover"
I understand to call the service I would use StartService(FolderRemover) but how would I pass the sting "Folder" to it?
Also the structure of the Service Module "FolderRemover" Im unsure where the code goes. i currently have it here
But cannot test as I cannot work out how to pass the "Folder" string to it!
So does the code look correct? and how do i pass the "Folder" string?
Sorry if I have it wrong, but I only used basic on the Atari ST and Amiga's so I have a lot of catching up to do.
Thanks
Aidy
I have a create a service module from a Sub in my main program. As my UI is using an animation to show the user that the app is working (similar to ProgressDialogShow) however as the sub is deleting a lot of files, in a folder, (100meg-2GB) This make the animation freeze for short periods. In a bid to make it look more professional. I would like a smooth animation. So its been suggested I use a service. I have never used a service myself and just want a little help rearranging the code!
This is the Sub
B4X:
Sub DeleteFolderRecursive(Folder As String)
For Each f As String In File.ListFiles(Folder)
If File.IsDirectory(Folder, f) Then
DeleteFolderRecursive (File.Combine(Folder, f))
End If
File.Delete(Folder, f)
DoEvents ' added to see its effect on the animation (without this the animation does not move, with it the animation is very jittery)
Next
End Sub
So I have created a service module "FolderRemover"
I understand to call the service I would use StartService(FolderRemover) but how would I pass the sting "Folder" to it?
Also the structure of the Service Module "FolderRemover" Im unsure where the code goes. i currently have it here
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
For Each f As String In File.ListFiles(Folder)
If File.IsDirectory(Folder, f) Then
DeleteFolderRecursive (File.Combine(Folder, f))
End If
File.Delete(Folder, f)
DoEvents
Next
End Sub
Sub Service_Destroy
End Sub
But cannot test as I cannot work out how to pass the "Folder" string to it!
So does the code look correct? and how do i pass the "Folder" string?
Sorry if I have it wrong, but I only used basic on the Atari ST and Amiga's so I have a lot of catching up to do.
Thanks
Aidy
Last edited: