using System; namespace Questionable.Controller.Steps.Common; internal abstract class AbstractDelayedTaskExecutor : TaskExecutor where T : class, ITask { private long _continueAtMs; 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(); _continueAtMs = Environment.TickCount64 + (long)Delay.TotalMilliseconds; return result; } protected abstract bool StartInternal(); public override ETaskResult Update() { if (Environment.TickCount64 < _continueAtMs) { return ETaskResult.StillRunning; } return UpdateInternal(); } protected virtual ETaskResult UpdateInternal() { return ETaskResult.TaskComplete; } }