/// <summary> /// Initializes a new instance of the <see cref="Timer"/> class. /// </summary> /// <param name="callback"> /// The callback to execute at each tick /// </param> /// <param name="maxFps"> /// The max tick per second /// </param> public Timer(TickDelegate callback, FpsLimiter maxFps = FpsLimiter.Fps30) { if (callback == null) { throw new ArgumentNullException("callback"); } this.callback = callback; this.MaxFps = maxFps; if (timerThread != null) return; timerThread = new Thread(ThreadCycle) { IsBackground = true }; timerThread.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="Timer"/> class. /// </summary> /// <param name="callback"> /// The callback to execute at each tick /// </param> /// <param name="maxFps"> /// The max tick per second /// </param> public Timer(TickDelegate callback, FpsLimiter maxFps = FpsLimiter.Fps30) { if (callback == null) { throw new ArgumentNullException("callback"); } this.callback = callback; this.MaxFps = maxFps; if (timerThread != null) { return; } timerThread = new Thread(ThreadCycle) { IsBackground = true }; timerThread.Start(); }