Skip to content

Commit

Permalink
可能修复了 FrameInfo 内存泄漏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Mar 5, 2024
1 parent a8ea30e commit 7c7c7ee
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,7 @@ private void SwitchFrameInfoPage()
frameInfoNavigationTimer.Stop();

FrameInfo.NavigationService.RemoveBackEntry();

frameInfoPageIndex++;
if (frameInfoPageIndex >= frameInfoPages.Count) frameInfoPageIndex = 0;
FrameInfo.Navigate(frameInfoPages[frameInfoPageIndex]);
Expand Down
9 changes: 9 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/CountdownPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public CountdownPage()
timer.Interval = TimeSpan.FromMilliseconds(100);
timer.Tick += Timer_Tick;
timer.Start();

Unloaded += Page_Unloaded;
}

private DispatcherTimer timer;
Expand All @@ -53,5 +55,12 @@ private void Timer_Tick(object sender, EventArgs e)
LabelDays.Content = timeSpan.Days;
LabelDaysDetail.Content = (timeSpan.TotalDays - timeSpan.Days).ToString(".000");
}

private void Page_Unloaded(object sender, EventArgs e)
{
timer.Stop();
timer.Tick -= Timer_Tick;
Unloaded -= Page_Unloaded;
}
}
}
9 changes: 9 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/DatePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public DatePage()
timer.Interval = TimeSpan.FromMilliseconds(500);
timer.Tick += Timer_Tick;
timer.Start();

Unloaded += Page_Unloaded;
}

private DispatcherTimer timer;
Expand All @@ -40,5 +42,12 @@ private void Timer_Tick(object sender, EventArgs e)
LabelDate.Content = DateTime.Now.ToString("yyyy 年 M 月 d 日");
LabelDayOfWeek.Content = DateTime.Now.ToString("dddd");
}

private void Page_Unloaded(object sender, EventArgs e)
{
timer.Stop();
timer.Tick -= Timer_Tick;
Unloaded -= Page_Unloaded;
}
}
}
9 changes: 9 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Pages/WeatherPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public WeatherPage()
timer.Interval = TimeSpan.FromHours(1);
timer.Tick += Timer_Tick;
timer.Start();

Unloaded += Page_Unloaded;
}

private DispatcherTimer timer = new DispatcherTimer();
Expand Down Expand Up @@ -130,5 +132,12 @@ private void ShowLiveWeather()
ImageWeather.Visibility = Visibility.Collapsed;
}
}

private void Page_Unloaded(object sender, EventArgs e)
{
timer.Stop();
timer.Tick -= Timer_Tick;
Unloaded -= Page_Unloaded;
}
}
}

0 comments on commit 7c7c7ee

Please sign in to comment.