Загрузка страницы

IDisposable Design Pattern (.Net Core)

In this video, I will walk through how to implement IDisposable Design Pattern.

We should use an IDisposable design pattern (or Dispose Pattern) when we need to dispose of unmanaged objects.

For implementing the IDisposable design pattern, the class which deals with unmanaged objects directly or indirectly should implement the IDisposable interface. And implement the method Dispose declared inside of the IDisposable interface.

Normally, we do not directly deal with unmanaged objects. But we deal with managed classes, which deals directly with unmanaged objects. For example, File handlers, connection string, HTTP streams, etc.

One important aspect of this pattern is that it makes easier for inherited classes to follow the IDisposable design pattern. And it is because of the implementation of an overridable Dispose method.

This pattern also suggests the use of the Finalizer method (or destructor in c#). However, if we use the Finalizer, it should be managed properly due to its performance implications. I have demonstrated the suggested implementation in the video.

Source code is available in my GitHub repository here: https://github.com/choudhurynirjhar/idisposable-demo

Видео IDisposable Design Pattern (.Net Core) канала DotNet Core Central
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
11 мая 2020 г. 6:00:04
00:12:29
Яндекс.Метрика