C11 app freezes up when Frame does Copy of files

Howdy All!

When I run this code my app freezes. Any ideas?
Thanks

Stacy

!Do BackupData
!BackupData Routine
CurrentPath = PATH()
If FiledialogA('Select backup folder',BackupFolder,'',FILE:KeepDir+FILE:Directory+FILE:LongName)     
    DIRECTORY(AllFiles,'*.*',ff_:READONLY+ff_:HIDDEN)   
    Loop iCounter = 1 To Records(AllFiles)   
      Get(AllFiles,iCounter)
      Copy(AllFiles.name,BackupFolder)
      AppFrame{Prop:StatusText,1} = 'Copying ' & Clip(CurrentPath) & '\' & AllFiles.Name
    End
    MESSAGE('Application copied to the ' & Clip(BackupFolder) & ' folder.','BACKUP',ICON:Exclamation)   
    AppFrame{Prop:StatusText,1} = ''
End  
SetPath(CurrentPath)

Running a lot of code like that without processing Events can make an App go “Not Responding” i.e. hang.

Put that code in a separate Window procedure. Use a Timer to Copy one or a few files each Event:Timer. A progress bar is nice for the user to know how long it will take.

Maybe this Repo will help you. It deletes a lot of Temp files using a Timer and shows a Progress.

2 Likes

Thanks kind sir! I will give it a try.