22 lines
722 B
C#
22 lines
722 B
C#
namespace ParadoxSaveParser.WebAPI.BackgroundTasks;
|
|
|
|
public class BackgroundJobManager
|
|
{
|
|
private readonly ILogger _parentLogger;
|
|
private long _lastJobId;
|
|
|
|
public BackgroundJobManager(ILogger logger)
|
|
{
|
|
_parentLogger = logger;
|
|
}
|
|
|
|
public SaveParsingOperation StartNewParsingOperation(
|
|
SaveFileMetadata meta, ISearchExpression searchQuery, CancellationToken ct)
|
|
{
|
|
long nextId = Interlocked.Increment(ref _lastJobId);
|
|
var contextLogger = new ContextLogger($"BackgroundJob-{nextId}", _parentLogger);
|
|
var op = new SaveParsingOperation(nextId, meta, searchQuery, contextLogger, ct);
|
|
op.StartAsync();
|
|
return op;
|
|
}
|
|
} |