C00225155-02/C00225155/MegaRobo.C00225155/MegaRobo.RRQuartz/JobManagerProvider.cs

28 lines
764 B
C#
Raw Normal View History

2026-04-13 09:12:49 +00:00
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace MegaRobo.RRQuartz;
public class JobManagerProvider
{
private readonly IDictionary<string, JobManager> _sources = new ConcurrentDictionary<string, JobManager>(StringComparer.CurrentCultureIgnoreCase);
public JobManager GetOrAdd(string name)
{
return this._sources.TryGetValue(name, out JobManager service) ? service : this.Create(name);
}
public JobManager Create(string name)
{
var service = new JobManager();
if(this._sources.ContainsKey(name))
{
this._sources[name] = service;
} else
{
this._sources.TryAdd(name, service);
}
return service;
}
}