using AsbCloudApp.Services; using System; using System.Collections.Concurrent; namespace AsbCloudInfrastructure.Services { class BackgroundQueue : IBackgroundQueue { private readonly ConcurrentQueue<(Action action, int id)> tasks = new ConcurrentQueue<(Action action, int id)>(); private int id = 0; public int EnqueueTask(Action action) { if (action == null) throw new ArgumentNullException(nameof(action)); id++; tasks.Enqueue(new(action, id)); return id; } public bool TryDequeue(out (Action action, int id) item) => tasks.TryDequeue(out item); } }