-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Description
From @ductrantb on Thursday, December 14, 2017 12:42:32 AM
Hi friends,
I have a problem with IOptionsSnapshot. I was tried to use BackgroundServiceManagerConfigsFactory as a transient service to renew configs on change.
services.AddTransient<BackgroundServiceManagerConfigsFactory, BackgroundServiceManagerConfigsFactory>();
services.AddSingleton<BackgroundServiceManager, BackgroundServiceManager>();
The constructor of my configs factory was called on every request (by singleton service), but configs value was not changed.
public BackgroundServiceManagerConfigs Configs { get; protected set; }
public BackgroundServiceManagerConfigsFactory(IOptionsSnapshot<BackgroundServiceManagerConfigs> options)
{
Configs = options.Value;
}
I tried to call this factory in a controller, it worked.
I used netcore 2.0 and Microsoft.Extensions.Options version 2.0.0.0
Thank you.
Copied from original issue: aspnet/Options#247
Metadata
Metadata
Assignees
Labels
No labels