Autofac. Dispose or not Dispose that is the question

1

Is there a difference in performance or best practices between the two examples?

Example1:

private void Teste()
{
    using (var scope = Container.BeginLifetimeScope())
    {
        scope.Resolve<MyViewModel>().ShowName();
    }
}

Example2:

private void Teste2()
{
    Resolver.Resolve<MyViewModel>().ShowName();
}
    
asked by anonymous 14.04.2015 / 02:46

1 answer

2

The ideal is always to make available resources that will no longer be used. LifeTimeScope serves just when multiple container features are used and when you dispose of LifeTimeScope, they are all freed from memory.

In the matter of performance it is better to do the dispose. link

    
24.04.2015 / 15:40