punish v6.8.18.0
This commit is contained in:
commit
060278c1b7
317 changed files with 554155 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
|
||||
namespace Questionable.Controller.Steps.Common;
|
||||
|
||||
internal abstract class AbstractDelayedTaskExecutor<T> : TaskExecutor<T> 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue