Skip to content

Commit

Permalink
Merge pull request unoplatform#15313 from Youssef1313/issues/15062
Browse files Browse the repository at this point in the history
perf(samplesapp): Make sure RefreshContainerPage timers are stopped
  • Loading branch information
jeromelaban authored Feb 2, 2024
2 parents ffe4fd3 + 085548d commit f8ccae1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 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,13 +50,10 @@ 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 f8ccae1

Please sign in to comment.