This repository was archived by the owner on Nov 7, 2018. It is now read-only.
This repository was archived by the owner on Nov 7, 2018. It is now read-only.
Thread safety in OptionsManager #88
Closed
Description
In the current implementation of OptionsManager, if I do something like this:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<MyOptions>(options => {
// some code, maybe not trivial
});
}
and then later, from multiple threads:
var options = services.GetRequiredService<IOptions<MyOptions>>().Value;
the configuration action may be invoked more than once, which is not intuitively expected.
If this is the desired behavior, it needs to be documented very clearly. Personally, I would prefer the options manager to deal with concurrency issues and guarantee that the configuration action is only invoked once.