From a65b93748c1cc54f905c2f8ee0b0bfaac928e5dc Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono <28079733+bagusnl@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:43:31 +0700 Subject: [PATCH] how is it not clear that idk what im doing --- .../MainApp/Pages/FileCleanupPage.xaml.cs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/FileCleanupPage.xaml.cs b/CollapseLauncher/XAMLs/MainApp/Pages/FileCleanupPage.xaml.cs index 3383aa476..ecd53d685 100644 --- a/CollapseLauncher/XAMLs/MainApp/Pages/FileCleanupPage.xaml.cs +++ b/CollapseLauncher/XAMLs/MainApp/Pages/FileCleanupPage.xaml.cs @@ -86,30 +86,34 @@ await Task.Run(() => sI.Stop(); Logger.LogWriteLine($"[FileCleanupPage::InjectFileInfoSource] Finished batch #{b} with {batch.Count} items after {s.ElapsedMilliseconds} ms", LogType.Scheme); b++; + sI = null; })); } }); await Task.WhenAll(tasks); - await EnqueueOnDispatcherQueueAsync(() => - { - var i = 0; - var sI = new Stopwatch(); - sI.Start(); - while (_localFileCollection.Count > 0) + if (_localFileCollection.Count > 0) + { + await EnqueueOnDispatcherQueueAsync(() => { - FileInfoSource.Add(_localFileCollection[0]); - _localFileCollection.RemoveAt(0); - i++; - } - - sI.Stop(); - Logger - .LogWriteLine($"[FileCleanupPage::InjectFileInfoSource] Finished last batch at #{b} after {i} items", - LogType.Scheme); - }); - + var i = 0; + var sI = new Stopwatch(); + sI.Start(); + while (_localFileCollection.Count > 0) + { + FileInfoSource.Add(_localFileCollection[0]); + _localFileCollection.RemoveAt(0); + i++; + } + + sI.Stop(); + Logger + .LogWriteLine($"[FileCleanupPage::InjectFileInfoSource] Finished last batch at #{b} after {i} items in {sI.ElapsedMilliseconds} ms", + LogType.Scheme); + }); + } + while (_localFileCollection.Count != 0) { FileInfoSource.Add(_localFileCollection[0]); @@ -131,7 +135,6 @@ await EnqueueOnDispatcherQueueAsync(() => DeleteSelectedFilesText.Text = string.Format(Locale.Lang._FileCleanupPage.BottomButtonDeleteSelectedFiles, 0); } - } private void UpdateUIOnCollectionChange(object? sender, NotifyCollectionChangedEventArgs? args)