I have the following very simple code in a drop object event on a Canvas:
If obj.FolderItemAvailable Then
Dim FolderSize As DirectorySizeMBS
// BuildStandbySheetDialog populates a predefined custom dialog with content
BuildStandbySheetDialog("Examining Source Volume", "Please stand by while the specified migration source is checked ...", Nil)
wStandbySheet.ShowWithin(Self)
wStandbySheet.Refresh
FolderSize = obj.FolderItem.CalculateDirectorySizeMBS
EstArchiveSize = FolderSize.PhysicalTotalSize // LogicalTotalSize
lSourceSize.Text = kSourceSize_text + SizeFromBytes(Format(EstArchiveSize, "#"))
wStandbySheet.Close
End If
However, the wStandbySheet window does not appear unit the processing is completed in the following statements - obviating its usefulness …
I’ve also tried moving the ShowWithin to a Timer with the same lack of results.
Does anyone have a magic incantation to get this working as the flow implies?
Hmm. The size calculation code is probably the culprit - it is probably tying up the main thread before it has a chance to make that sheet window show up.
I suggest you move all the code that does the actual work into the window itself, triggered by the Open(ed) event. This will ensure that it only starts once the window is actually visible.
I’ve now added a Thread to the window and moved the CalculateDirectorySizeMBS call into that - same result. @Christian_Schmitz - are you blocking background events in that function?
The YieldTicks works fine for an intermediate number of folderitems. If I select a super large folder like my copy of the 1.4 million Enron emails then I still get the beachball.
A while ago I did some testing with Instruments and accessing the folderitems was the bottleneck.
Add a timer to the standbysheet
Show the standysheet
Start the timer
launch the GetSize code in a thread
Have the timer check now and then whether the thread is complete, and close when it is ?
Tried this up to 100 ticks with no change. Should this be in in the Thread before Calling CalculateDirectorySizeMBS, or as a global or protected call in the Window’s open?
I imagine a worker would help in this scenario. However, the fact that a few lines of code have to moved into a separate app to solve this problem highlights a significant limitation in Xojo.
Not only did that (True, 3) allow the dialog to appear, but it also makes the calculation task complete recognizably faster - even on a 122TB folder hierarchy, the pacifier dialog wasn’t even necessary.
Without those parameters, the 122TB folder caused the beach ball to appear and stall the UI for over 18 seconds. With the parameters of True and 3, it finishes in less time than it takes my Pacifier dialog to appear and be visible - sub 2 seconds by simple counting.