Skip to content

Commit

Permalink
perf(samplesapp): Make sure RefreshContainerPage timers are stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Feb 1, 2024
1 parent e3b635d commit ee59ded
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public RefreshContainerOnImagePage()
{
this.InitializeComponent();
this.Loaded += OnMainPageLoaded;

this.Unloaded += OnMainPageUnloaded;
timer.Interval = new TimeSpan(0, 0, 0, 0, 800);
timer.Tick += Timer_Tick;
}
Expand All @@ -50,11 +50,9 @@ public RefreshContainerOnImagePage()
private bool delayRefresh = true;
private int refreshCount = 0;

protected
#if HAS_UNO
internal
#endif
override void OnNavigatedFrom(NavigationEventArgs e)
// Uno specific: Unlike WinUI, we unsubscribe on Unloaded because we don't get OnNavigatedFrom.
// See point #2 in https://github.com/unoplatform/uno/issues/15059#issuecomment-1891551501
private void OnMainPageUnloaded(object sender, RoutedEventArgs e)
{
base.OnNavigatedFrom(e);
timer.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public RefreshContainerPage()
{
this.InitializeComponent();
this.Loaded += OnMainPageLoaded;
this.Unloaded += OnMainPageUnloaded;

containerTimer.Interval = new TimeSpan(0, 0, 0, 5, 0);
containerTimer.Tick += containerTimer_Tick;
Expand All @@ -68,13 +69,10 @@ public RefreshContainerPage()
LogController.InitializeLogging();
}

protected
#if HAS_UNO
internal
#endif
override void OnNavigatedFrom(NavigationEventArgs e)
// Uno specific: Unlike WinUI, we unsubscribe on Unloaded because we don't get OnNavigatedFrom.
// See point #2 in https://github.com/unoplatform/uno/issues/15059#issuecomment-1891551501
private void OnMainPageUnloaded(object sender, RoutedEventArgs e)
{
base.OnNavigatedFrom(e);
containerTimer.Stop();
visualizerTimer.Stop();
}
Expand Down

0 comments on commit ee59ded

Please sign in to comment.