improve:计时器
This commit is contained in:
@@ -31,6 +31,8 @@ namespace Ink_Canvas
|
||||
updateTimer = new System.Timers.Timer(100);
|
||||
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
||||
updateTimer.Start();
|
||||
|
||||
parentWindow.TimerCompleted += ParentWindow_TimerCompleted;
|
||||
}
|
||||
|
||||
private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
@@ -70,6 +72,14 @@ namespace Ink_Canvas
|
||||
SetDigitDisplay("FullSecond2Display", seconds % 10);
|
||||
}
|
||||
}
|
||||
|
||||
private void ParentWindow_TimerCompleted(object sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
this.Close();
|
||||
});
|
||||
}
|
||||
|
||||
private void SetDigitDisplay(string pathName, int digit)
|
||||
{
|
||||
@@ -116,6 +126,11 @@ namespace Ink_Canvas
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (parentWindow != null)
|
||||
{
|
||||
parentWindow.TimerCompleted -= ParentWindow_TimerCompleted;
|
||||
}
|
||||
|
||||
// 清理资源
|
||||
if (updateTimer != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user