mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-04 09:54:16 +02:00
Fix Worker-Cycle:
Periodic set last execution, Print Running Worker-Names when done
This commit is contained in:
@ -88,6 +88,8 @@ public abstract class BaseWorker : Identifiable
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
Log.Info($"Completed {this}\n\t{endTime.Subtract(startTime).TotalMilliseconds} ms");
|
||||
this.State = WorkerExecutionState.Completed;
|
||||
if(this is IPeriodic periodic)
|
||||
periodic.LastExecution = DateTime.UtcNow;
|
||||
});
|
||||
task.Start();
|
||||
this.State = WorkerExecutionState.Running;
|
||||
|
@ -2,7 +2,7 @@ namespace API.Workers;
|
||||
|
||||
public interface IPeriodic
|
||||
{
|
||||
protected DateTime LastExecution { get; set; }
|
||||
internal DateTime LastExecution { get; set; }
|
||||
public TimeSpan Interval { get; set; }
|
||||
public DateTime NextExecution => LastExecution.Add(Interval);
|
||||
public bool IsDue => NextExecution <= DateTime.UtcNow;
|
||||
|
Reference in New Issue
Block a user