mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Wabbajack.BuildServer.Model.Models;
|
|
using Wabbajack.Common;
|
|
|
|
namespace Wabbajack.BuildServer.BackendServices
|
|
{
|
|
public abstract class ABackendService
|
|
{
|
|
protected ABackendService(SqlService sql, AppSettings settings, TimeSpan pollRate)
|
|
{
|
|
Sql = sql;
|
|
Settings = settings;
|
|
PollRate = pollRate;
|
|
}
|
|
|
|
public TimeSpan PollRate { get; }
|
|
|
|
public async Task RunLoop(CancellationToken token)
|
|
{
|
|
while (!token.IsCancellationRequested)
|
|
{
|
|
try
|
|
{
|
|
await Execute();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Utils.Log($"Error executing {this}");
|
|
Utils.Log(ex.ToString());
|
|
}
|
|
|
|
await Task.Delay(PollRate);
|
|
}
|
|
|
|
}
|
|
|
|
public abstract Task Execute();
|
|
|
|
protected AppSettings Settings { get; set; }
|
|
|
|
protected SqlService Sql { get; set; }
|
|
}
|
|
}
|