boten Active Member Licensed User Longtime User Mar 5, 2016 #1 Yet another "doevents" question - recursive task My app should scan recursively all the directories on a hard disk. For each file in a directory: do something (e.g: save names, date & size of all files) for each sub-directory: do it all over again..... Show a tree of all directories I have the logic; the sub to scan 1 directory (given it's full path and the "branch" of the tree it is on) is as follows: Find all "files", if a file - do what needed if a directory - call the sub again with a new child "branch" and augmented path The problem is that during the scan, the prog seems to "freeze": I want to show the progress of the scan by displaying the current path on a label and also show a progressbar. but since the prog is still processing the disk, no updating is done. Using a timer seemed to present itself as the solution, BUT... The problem is that the parameters for the sub (branch,path) are generated within the sub itself on a "higher level" so "quitting" the sub in order to wait for the timer to tick will lose the parms. Any idea on how to be able to update the GUI while the scan is on?
Yet another "doevents" question - recursive task My app should scan recursively all the directories on a hard disk. For each file in a directory: do something (e.g: save names, date & size of all files) for each sub-directory: do it all over again..... Show a tree of all directories I have the logic; the sub to scan 1 directory (given it's full path and the "branch" of the tree it is on) is as follows: Find all "files", if a file - do what needed if a directory - call the sub again with a new child "branch" and augmented path The problem is that during the scan, the prog seems to "freeze": I want to show the progress of the scan by displaying the current path on a label and also show a progressbar. but since the prog is still processing the disk, no updating is done. Using a timer seemed to present itself as the solution, BUT... The problem is that the parameters for the sub (branch,path) are generated within the sub itself on a "higher level" so "quitting" the sub in order to wait for the timer to tick will lose the parms. Any idea on how to be able to update the GUI while the scan is on?
Daestrum Expert Licensed User Longtime User Mar 5, 2016 #2 It's probably easier to put the scan part in a task then use bind to get the data to update the GUI controls. example of java code I use to update a progress bar and label whilst the main task is running. Code: ... la.textProperty().bind(task.messageProperty()); pb.progressProperty().bind(task.progressProperty()); ... Whenever I update messageProperty inside the task , the change is immediately reflected in the label (la) and progressProperty for the progressbar (pb). Last edited: Mar 5, 2016 Upvote 0
It's probably easier to put the scan part in a task then use bind to get the data to update the GUI controls. example of java code I use to update a progress bar and label whilst the main task is running. Code: ... la.textProperty().bind(task.messageProperty()); pb.progressProperty().bind(task.progressProperty()); ... Whenever I update messageProperty inside the task , the change is immediately reflected in the label (la) and progressProperty for the progressbar (pb).
jmon Well-Known Member Licensed User Longtime User Mar 5, 2016 #3 You can use callSubDelayed to call the next loop. Otherwise, on windows, what I do is calling "Dir" with Shell (or jShellQueue , in my signature): Code: Queue.AddToQueue("cmd.exe", Array("/c", "dir", Path.ToString, "/b", "/s", "/n"), _ Dir is much faster than any code you could write. You can process the returned text by splitting with CRLF. Upvote 0
You can use callSubDelayed to call the next loop. Otherwise, on windows, what I do is calling "Dir" with Shell (or jShellQueue , in my signature): Code: Queue.AddToQueue("cmd.exe", Array("/c", "dir", Path.ToString, "/b", "/s", "/n"), _ Dir is much faster than any code you could write. You can process the returned text by splitting with CRLF.
boten Active Member Licensed User Longtime User Mar 6, 2016 #4 Solved it with a "stack" (list) of sub-dirs instead of recursion Upvote 0