You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have registered instance A of interface IA.
Sometimes when I resolve an interface IA and dispose a scope from concurrent thread I get DependencyResolutionException while ObjectDisposedException is expected.
Sample test to reproduce:
private interface IA
{
}
private class A : IA
{
}
[Fact]
public async Task RepeatedResolveExternallyOwnedInstanceWhileTheScopeIsDisposing_ObjectDisposedExceptionThrownOnly()
{
for (int i = 0; i < 200; i++)
{
await ResolveExternallyOwnedInstanceWhileTheScopeIsDisposing_ObjectDisposedExceptionThrownOnly();
}
}
private async Task ResolveExternallyOwnedInstanceWhileTheScopeIsDisposing_ObjectDisposedExceptionThrownOnly()
{
var cb = new ContainerBuilder();
var container = cb.Build();
var scope = container.BeginLifetimeScope(
"name", builder =>
{
var a = new A();
builder.RegisterInstance<IA>(a);
});
var t = Task.Run(
() =>
{
try
{
while (true)
{
scope.Resolve<IA>();
}
}
catch (ObjectDisposedException e)
{
}
});
await Task.Delay(5);scope.Dispose();
await t;
}
The text was updated successfully, but these errors were encountered:
I have registered instance
A
of interfaceIA
.Sometimes when I resolve an interface
IA
and dispose a scope from concurrent thread I getDependencyResolutionException
whileObjectDisposedException
is expected.Sample test to reproduce:
The text was updated successfully, but these errors were encountered: