-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTimerExtensions.cs
37 lines (37 loc) · 1.19 KB
/
TimerExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace VolumeControl.TypeExtensions
{
/// <summary>
/// Extensions for the <see cref="System.Windows.Forms.Timer"/> timer object.
/// </summary>
public static class TimerExtensions
{
/// <summary>
/// Resets the timer back to default if it was already started; otherwise does nothing.
/// </summary>
/// <param name="timer">The timer instance this method is called on.</param>
public static void Reset(this System.Windows.Forms.Timer timer)
{
if (timer.Enabled)
{
timer.Enabled = false;
timer.Enabled = true;
}
}
/// <summary>
/// Resets the timer back to default if it was already started; otherwise the timer is started.
/// </summary>
/// <param name="timer">The timer instance this method is called on.</param>
public static void StartOrReset(this System.Windows.Forms.Timer timer)
{
if (timer.Enabled)
{
timer.Enabled = false;
timer.Enabled = true;
}
else
{
timer.Enabled = true;
}
}
}
}