diff --git a/SampleApps/WinUiApp/MainWindow.xaml.cs b/SampleApps/WinUiApp/MainWindow.xaml.cs index 016bfa96..d0bd3c77 100644 --- a/SampleApps/WinUiApp/MainWindow.xaml.cs +++ b/SampleApps/WinUiApp/MainWindow.xaml.cs @@ -42,16 +42,20 @@ namespace WinUiApp root.DataContext = viewModel; - if (TileImageLoader.Cache is ImageFileCache cache) + if (TileImageLoader.Cache is ImageFileCache) { - Activated += async (s, e) => - { - await Task.Delay(2000); - await cache.Clean(); - }; + Activated += WindowActivated; } } + private async void WindowActivated(object sender, WindowActivatedEventArgs e) + { + Activated -= WindowActivated; + + await Task.Delay(2000); + await ((ImageFileCache)TileImageLoader.Cache).Clean(); + } + private void SeamarksChecked(object sender, RoutedEventArgs e) { map.Children.Insert(map.Children.IndexOf(graticule), viewModel.MapLayers.SeamarksLayer); @@ -61,5 +65,10 @@ namespace WinUiApp { map.Children.Remove(viewModel.MapLayers.SeamarksLayer); } + + private void MapViewportChanged(object sender, ViewportChangedEventArgs e) + { + GC.Collect(); + } } }