private async void Modified(string Path) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async() => { try { await Locker.WaitAsync(); try { if (CurrentLocation == System.IO.Path.GetDirectoryName(Path)) { if (await FileSystemStorageItemBase.OpenAsync(Path) is FileSystemStorageItemBase ModifiedItem) { PathConfiguration Config = SQLite.Current.GetPathConfiguration(CurrentLocation); FileSystemStorageItemBase OldItem = CurrentCollection.FirstOrDefault((Item) => Item.Path.Equals(Path, StringComparison.OrdinalIgnoreCase)); if (OldItem != null) { if (ModifiedItem.GetType() == OldItem.GetType()) { await OldItem.RefreshAsync(); } else { CurrentCollection.Remove(OldItem); if (!SettingControl.IsDisplayProtectedSystemItems || !ModifiedItem.IsSystemItem) { if ((ModifiedItem is IHiddenStorageItem && SettingControl.IsDisplayHiddenItem) || ModifiedItem is not IHiddenStorageItem) { if (CurrentCollection.Any()) { int Index = SortCollectionGenerator.SearchInsertLocation(CurrentCollection, ModifiedItem, Config.SortTarget.GetValueOrDefault(), Config.SortDirection.GetValueOrDefault()); if (Index >= 0) { CurrentCollection.Insert(Index, ModifiedItem); } else { CurrentCollection.Add(ModifiedItem); } } else { CurrentCollection.Add(ModifiedItem); } } } } } else if (ModifiedItem is not IHiddenStorageItem) { if (CurrentCollection.Any()) { int Index = SortCollectionGenerator.SearchInsertLocation(CurrentCollection, ModifiedItem, Config.SortTarget.GetValueOrDefault(), Config.SortDirection.GetValueOrDefault()); if (Index >= 0) { CurrentCollection.Insert(Index, ModifiedItem); } else { CurrentCollection.Add(ModifiedItem); } } else { CurrentCollection.Add(ModifiedItem); } } } } } finally { Locker.Release(); } } catch (Exception ex) { LogTracer.Log(ex, $"{ nameof(StorageAreaWatcher)}: Modify item in collection failed"); } });