//--------------------------------------------------------------------- public EbTimer(TimerShaft timer_shaft, ulong tm, Action cb) { TimerShaft = timer_shaft; TmSpan = tm; FuncCb = cb; LastTimeJeffies = TimerShaft.GetTimeJeffies() + TmSpan; Closed = false; var time_ev = new EbTimeEvent() { mExpires = TimerShaft.GetTimeJeffies() + TmSpan, onTime = _onTimer, mData = null }; TimerShaft.AddTimer(time_ev); }
//--------------------------------------------------------------------- void _onTimer(object data) { if (Closed) { return; } LastTimeJeffies += TmSpan; var delta_tm = LastTimeJeffies - TimerShaft.GetTimeJeffies(); var time_ev = new EbTimeEvent() { mExpires = TimerShaft.GetTimeJeffies() + delta_tm, onTime = _onTimer, mData = null }; TimerShaft.AddTimer(time_ev); FuncCb(); }