diff --git a/EnvelopeGenerator.ServiceHost/Jobs/JobStateManager.cs b/EnvelopeGenerator.ServiceHost/Jobs/JobStateManager.cs new file mode 100644 index 00000000..fa298698 --- /dev/null +++ b/EnvelopeGenerator.ServiceHost/Jobs/JobStateManager.cs @@ -0,0 +1,19 @@ +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 +} \ No newline at end of file