-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTimer.Service.cs
24 lines (23 loc) · 912 Bytes
/
Timer.Service.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
using System.Timers;
namespace Services
{
internal class TimerService
{
/// <summary>
/// Creates and automatically starts a timer
/// </summary>
/// <param name="milliseconds">milliseconds until the next tick</param>
/// <param name="elapsedEventHandler">Event handler that will be called every tick</param>
/// <param name="autoReset">should timer be automatically reset</param>
/// <param name="enabled">should timer be enabled</param>
/// <returns>The timer instance</returns>
public Timer CreateTimer(int milliseconds, ElapsedEventHandler elapsedEventHandler, bool autoReset, bool enabled)
{
Timer timer = new Timer(milliseconds);
timer.Elapsed += elapsedEventHandler;
timer.AutoReset = autoReset;
timer.Enabled = enabled;
return timer;
}
}
}