28 lines
681 B
C#
28 lines
681 B
C#
using Hcs.WebApp.Data.Hcs;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Hcs.WebApp.BackgroundServices
|
|
{
|
|
public class CampaignManagementState
|
|
{
|
|
private readonly ConcurrentQueue<Campaign> campaigns = new();
|
|
|
|
public event Action<Campaign> OnCampaignStarted;
|
|
|
|
public void EnqueueCampaign(Campaign campaign)
|
|
{
|
|
campaigns.Enqueue(campaign);
|
|
}
|
|
|
|
public bool TryDequeueCampaign(out Campaign campaign)
|
|
{
|
|
return campaigns.TryDequeue(out campaign);
|
|
}
|
|
|
|
public void InvokeOnCampaignStarted(Campaign campaign)
|
|
{
|
|
OnCampaignStarted?.Invoke(campaign);
|
|
}
|
|
}
|
|
}
|