using AngleSharp.Common; using System.Collections.Concurrent; namespace EnvelopeGenerator.ServiceHost.Jobs; public class JobStateManager(Dictionary? initialState = null) { private readonly ConcurrentDictionary _states = new(); public State GetState() => _states.GetOrAdd(typeof(TJob), type => initialState?.GetOrDefault(type.Name, State.Stopped) ?? State.Stopped); public State SetState(State state) => _states[typeof(TJob)] = state; } public enum State { Running, Stopped }