I need to handle a large amount of separated queues, the queues need to be separated but handled in the same way, I don’t want to setup multiple queue-functions so I thought of this solution but I’m not sure it’s a safe way to do:
var connectors = GetTheConnectors();
var tasks = new List<Task>();
foreach (var item in connectors)
{
var task = Task.Factory.StartNew(() => {
var host = new JobHost(new JobHostConfiguration
{
NameResolver = new QueueNameResolver(item.Name)
});
host.RunAndBlock();
});
tasks.Add(task);
}
Task.WaitAll(tasks.ToArray());
If not, Do anyone have a better solution?