private ITaskFactory CreateTaskFactoryInternal(ATaskScheduler scheduler, bool weOwnScheduler)
{
if (weOwnScheduler)
{
var container = _createContainerInternal().Create(QueueContexts.TaskFactory, _registerService, _transportInit,
serviceRegister => serviceRegister.Register(() => scheduler, LifeStyles.Singleton), _setOptions);
Containers.Add(container);
return container.GetInstance<ITaskFactory>();
}
else
{
var container = _createContainerInternal().Create(QueueContexts.TaskFactory, _registerService, _transportInit,
serviceRegister => serviceRegister.RegisterNonScopedSingleton(scheduler), _setOptions);
Containers.Add(container);
return container.GetInstance<ITaskFactory>();
}
}