/// <summary> /// Construct new timer. /// </summary> /// <param name="timeoutHandler">timeout handler</param> /// <param name="cancelHandler">timer cancel handler, optional</param> public Timer(TimeoutHandler timeoutHandler, TimerCancelHandler cancelHandler = null) { _timeoutHandler = timeoutHandler; _cancelHandler = cancelHandler; _nativeTimeoutDeleg = _OnTimeout; _nativeCancelDeleg = _OnCancel; _nativeTimer = LLBCNative.csllbc_Timer_Create(_nativeTimeoutDeleg, _nativeCancelDeleg); }
/// <summary> /// Schedule timer, same with Non-Static Schedule(DateTime, double) method. /// </summary> /// <param name="timeoutHandler">Timeout handler</param> /// <param name="firstTimeoutTime">first timeout time</param> /// <param name="period">period, in seconds</param> /// <param name="cancelHandler">timer cancel handler</param> /// <returns>new timer object</returns> public static Timer Schedule(TimeoutHandler timeoutHandler, DateTime firstTimeoutTime, double period = 0.0, TimerCancelHandler cancelHandler = null) { Timer timer = new Timer(timeoutHandler, cancelHandler); timer.Schedule(firstTimeoutTime, period); return(timer); }
/// <summary> /// Schedule timer, same with Non-Static Schedule(DateTime, double) method. /// </summary> /// <param name="timeoutHandler">Timeout handler</param> /// <param name="firstTimeoutTime">first timeout time</param> /// <param name="period">period, in seconds</param> /// <param name="cancelHandler">timer cancel handler</param> /// <returns>new timer object</returns> public static Timer Schedule(TimeoutHandler timeoutHandler, DateTime firstTimeoutTime, double period = 0.0, TimerCancelHandler cancelHandler = null) { Timer timer = new Timer(timeoutHandler, cancelHandler); timer.Schedule(firstTimeoutTime, period); return timer; }