using System; namespace Questionable.Controller.Steps.Common; internal abstract class AbstractDelayedTaskExecutor : TaskExecutor where T : class, ITask { private DateTime _continueAt; protected TimeSpan Delay { get; set; } protected AbstractDelayedTaskExecutor() : this(TimeSpan.FromSeconds(5L)) { } protected AbstractDelayedTaskExecutor(TimeSpan delay) { Delay = delay; } protected sealed override bool Start() { bool result = StartInternal(); _continueAt = DateTime.Now.Add(Delay); return result; } protected abstract bool StartInternal(); public override ETaskResult Update() { if (_continueAt >= DateTime.Now) { return ETaskResult.StillRunning; } return UpdateInternal(); } protected virtual ETaskResult UpdateInternal() { return ETaskResult.TaskComplete; } }