CleanArchitecture.WorkerService
CleanArchitecture.WorkerService copied to clipboard
{"Cannot access a disposed object.\r\nObject name: 'IServiceProvider'."} after multiple runs
I added the ServiceLocator in #3. I've now found that when I run the service for multiple loops, we get {"Cannot access a disposed object.\r\nObject name: 'IServiceProvider'."}.
I'm unable to reproduce with this unit test, I only get it at run time. Here was my attempt at a test.
[Fact]
public async Task MessageWasRetrievedFromTheQueue_WorksManyTimes()
{
// simulate multiple runs
// avoid {"Cannot access a disposed object.\r\nObject name: 'IServiceProvider'."}
var (service, _, _, _, _) = Factory();
await service.ExecuteAsync();
await service.ExecuteAsync();
await service.ExecuteAsync();
await service.ExecuteAsync();
var (service2, _, _, _, _) = Factory();
await service2.ExecuteAsync();
var (service3, _, _, _, _) = Factory();
await service3.ExecuteAsync();
Assert.True(true);
}
Should be fixed now I hope.