Last post Jul 23, 2018 07:52 AM by Yohann Lu
Jul 22, 2018 09:42 PM|neoaguil17|LINK
I see the following code:
public class AgenteAdministracion : IDisposable
private readonly IServiceConsumer<IServicioAdministracion> proxy;
proxy = ServiceConsumerFactory.Create<IServicioAdministracion>(() => new ServicioAdministracionClient());
public async Task<T> InvocarFuncionAsync<T>(Expression<Func<IServicioAdministracion, Task<T>>> func)
var result = await proxy.ConsumeAsync<T>(func);
public async Task InvocarAccionAsync(Expression<Func<IServicioAdministracion, Task>> func)
var result = await proxy.ConsumeAsync(func);
public void Dispose()
if (proxy != null)
}What is the function of IDisposable in this code.
Jul 23, 2018 04:33 AM|vahid bakkhi|LINK
IDisposable is an interface that contains a single method, Dispose(), for releasing unmanaged resources, like files, streams, database connections and so on. This method is implemented explicitly in the code when we need to clean up a disposable object and
to release unmanaged resources that this disposable object holds.
The Dispose method is implemented explicitly by the programmer and there is the chance that the programmer fails or forgets to dispose of the unmanaged resources, so the Finalize method should be called for a safer side to prevent a memory leak. If the Dispose
method is not called for any reason then the destructor would be called by the garbage collector, but when the Finalize method would be called by the garbage collector is not determined. The garbage collector can call it anytime there is a requirement of more
memory or when the program exits or anytime on some other conditions.
Jul 23, 2018 07:52 AM|Yohann Lu|LINK
What is the function of IDisposable in this code.
Interface:Provides a mechanism for releasing unmanaged resources.
Cleaning Up Unmanaged Resources:
The following links for your reference.
Understanding and Implementing IDisposable Interface - A Beginner's Tutorial