public void Schedule <TWork>(ModelBase model, TWork work) where TWork : Work { /* * rabbitmq/rabbitmq-dotnet-client#841 * https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2.getoradd * Note that the value delegate is not atomic but the Schedule method will not be called concurrently. */ WorkPool workPool = _workPools.GetOrAdd(model, _startNewWorkPoolFunc); workPool.Enqueue(work); }
public void AddWork(IModel model, Action fn) { /* * rabbitmq/rabbitmq-dotnet-client#841 * https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2.getoradd * Note that the value delegate is not atomic but the AddWork method will not be called concurrently. */ WorkPool workPool = _workPools.GetOrAdd(model, _startNewWorkPoolFunc); workPool.Enqueue(fn); }