Skip to content

Commit

Permalink
Timers now disposed of individually instead of in component
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsoltGajdacs committed Feb 7, 2019
1 parent 5c84ebb commit baf880e
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions BlinkReminder/Windows/TaskbarPresence.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public partial class TaskbarPresence : Window, IDisposable
private const string TOOLTIP_SHORT_DISABLED = "Short breaks are disabled";
private const int ONE_MINUTE_IN_MS = 60000;

// Component holder for disposal
private IContainer components;

// Keyboard input catcher
private KeyboardHook keyTrap;

Expand Down Expand Up @@ -102,14 +99,6 @@ private void SetDefaultValues()
tooltipRefreshTimer.AutoReset = true;
tooltipRefreshTimer.Elapsed += TaskbarTimer_Elapsed;

// Component for disposal
components = new Container();

// Add to Component holder for proper disposal later
components.Add(shortIntervalTimer);
components.Add(longIntervalTimer);
components.Add(tooltipRefreshTimer);

isShortIntervalTimerDone = false;
isLongIntervalTimerDone = false;
}
Expand Down Expand Up @@ -524,8 +513,6 @@ private void StartPauseTimer(double amountMillisec)
};
pauseTimer.Elapsed += PauseTimer_Elapsed;
pauseTimer.Start();

components.Add(pauseTimer);
}

/// <summary>
Expand Down Expand Up @@ -668,7 +655,10 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
components.Dispose();
shortIntervalTimer.Dispose();
longIntervalTimer.Dispose();
tooltipRefreshTimer.Dispose();
pauseTimer.Dispose();
taskbarIcon.Dispose();

if (keyTrap != null)
Expand Down

0 comments on commit baf880e

Please sign in to comment.