public void Schedule(ScheduleType type) { if (type == ScheduleType.Once && TimesExecuted > 0) { return; } logger.Info($"{Id} due in {TimeUntil}"); var difference = CalculateDifference(); thread = new Thread(() => { Thread.Sleep((int)difference.TotalMilliseconds); if (type == ScheduleType.RepeatOnWeekDays && !dateProvider.IsWeekend()) { foreach (var action in Actions) { action(); } TimesExecuted++; } Schedule(type); }); thread.Start(); }