public InternalTimer(int delay, int interval, TimerCallbackDelegate callback, ILogger logger) { this.delay = delay; this.interval = interval; var context = new EventContext <TimerCallbackDelegate>(callback, cb => cb(DateTime.Now), logger); timer = new System.Threading.Timer(state => context.Invoke(), null, Timeout.Infinite, interval); }
/// <param name="name">Name of the timer.</param> /// <param name="duration">Duration you want the timer to run for. (Seconds)</param> /// <param name="deleteOnFinish">Should the timer delete itself when finished? (Callback function will still be called)</param> /// <param name="callback">Delegate (function) to be called when the timer has finished; use null if no function callback is required. (Function must have no parameters)</param> public void Initialize(string name, float duration, bool deleteOnFinish, TimerCallbackDelegate callback) { m_HasBeenInitialized = true; TimerName = name; m_Duration = duration; m_Callback = callback; m_DeleteOnFinish = deleteOnFinish; m_OnFinish = false; }
public TimerAbsolute(TimerCallbackDelegate cb) : base() { if (cb == null) { throw new Exception("Call back is NULL"); } callback = cb; this.Elapsed += this.ElapsedAction; this.AutoReset = true; }
/// <summary> /// Creates a new timer. /// </summary> /// <param name="interval">The number of milliseconds to delay until the callback is called.</param> /// <param name="callback">The callback to call.</param> /// <param name="param">User data to pass the callback.</param> /// <returns>The timer.</returns> public static Timer Add(uint interval, TimerCallbackDelegate callback, IntPtr param) => new Timer(Native.SDL_AddTimer(interval, callback, param).Id, callback);
private Timer(int id, TimerCallbackDelegate callback) { _callback = callback; _id = id; }
/// <summary> /// Creates an instance of the Multimedia Timer. /// </summary> public Multimedia() { _callback = new TimerCallbackDelegate(TimerCallbackMethod); Resolution = 0; Interval = 1; }
public static extern MMRESULT TimeSetEvent(uint msDelay, uint msResolution, TimerCallbackDelegate callback, ref uint userCtx, uint eventType);