Autofac. Dispose or not

Asked

Viewed 70 times

1

There is a difference in performance or best practice between the two examples?

Example1:

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

Exemplo2:

private void Teste2()
{
    Resolver.Resolve<MyViewModel>().ShowName();
}

1 answer

2


The ideal is to always do the Dispose of the resources that will no longer be used. Lifetimescope serves precisely when multiple container features are used and when doing Lifetimescope Device, they are all released from memory.

When it comes to performance it’s best to do Disposis. http://docs.autofac.org/en/latest/lifetime/disposal.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.