Start operation implementation
This commit is contained in:
27
Hcs.WebApp/BackgroundServices/OperationExecutionState.cs
Normal file
27
Hcs.WebApp/BackgroundServices/OperationExecutionState.cs
Normal file
@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user