public IPendingTask ScheduleOnInterval(Action action, long firstInMs, long regularInMs, bool shortLiving = false) { var pending = new PendingTask(action, firstInMs, regularInMs, _logger, shortLiving); pending.Schedule(); lock (_listLock) { _tasks.Add(pending); } return(pending); }
public IPendingTask ScheduleOnInterval(Func <Task> action, long firstInMs, long regularInMs, bool shortLiving = false) { var pending = new PendingTask(async() => { try { await action(); } catch (Exception e) { _logger?.Error($"ScheduleOnIntervalAsync task error: {e}"); } }, firstInMs, regularInMs, _logger, shortLiving); pending.Schedule(); lock (_listLock) { _tasks.Add(pending); } return(pending); }