28 lines
700 B
C#
28 lines
700 B
C#
using Hcs.WebApp.Data.Hcs;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Hcs.WebApp.BackgroundServices
|
|
{
|
|
public class OperationExecutionState
|
|
{
|
|
private readonly ConcurrentQueue<Operation> operations = new();
|
|
|
|
public event Action<Operation> OnOperationStarted;
|
|
|
|
public void EnqueueOperation(Operation operation)
|
|
{
|
|
operations.Enqueue(operation);
|
|
}
|
|
|
|
public bool TryDequeueOperation(out Operation operation)
|
|
{
|
|
return operations.TryDequeue(out operation);
|
|
}
|
|
|
|
public void InvokeOnOperationStarted(Operation operation)
|
|
{
|
|
OnOperationStarted?.Invoke(operation);
|
|
}
|
|
}
|
|
}
|