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
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
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![IDisposable and Finalizers](https://i.ytimg.com/vi/nQCoy9csNk4/default.jpg)
![Scheduling recurring jobs with Hangfire (In ASP.Net Core 3.1)](https://i.ytimg.com/vi/sQyY0xvJ4-o/default.jpg)
![Finalize vs Dispose | C# Interview Questions](https://i.ytimg.com/vi/6_Upud25iFQ/default.jpg)
![](https://i.ytimg.com/vi/T_XH07hGDjI/default.jpg)
![Get Connection String for Dapper and EFCore (Web or Console App) [Dotnet5] [2021]](https://i.ytimg.com/vi/dbZ01qMRIfM/default.jpg)
![](https://i.ytimg.com/vi/KuSSRUhZEWw/default.jpg)
![The Dispose Pattern](https://i.ytimg.com/vi/CV5UlcfFls4/default.jpg)
![Memento Design Pattern (An Introduction for .NET Developers [.NET 6 and C# 10])](https://i.ytimg.com/vi/G82F85SqYUs/default.jpg)
![GraphQL - Running Queries (An introduction for .NET Developers [Using .NET 6 and C# 10])](https://i.ytimg.com/vi/gEApqKuWvSg/default.jpg)
![Coding Shorts: IDisposable and IAsyncDisposable in C#](https://i.ytimg.com/vi/mG4PFlajbzs/default.jpg)
![asp.net core - MediatR (CQRS) Tutorial & Tips](https://i.ytimg.com/vi/xKKVW94F2bc/default.jpg)
![Factory Design Pattern in C# with example](https://i.ytimg.com/vi/I2il8ZsDkLU/default.jpg)
![8 await async mistakes that you SHOULD avoid in .NET](https://i.ytimg.com/vi/lQu-eBIIh-w/default.jpg)
![C# Advanced Async - Getting progress reports, cancelling tasks, and more](https://i.ytimg.com/vi/ZTKGRJy5P2M/default.jpg)
![C# Finalize vs Dispose Method | 2020](https://i.ytimg.com/vi/r7KgN-AprTM/default.jpg)
![ASP.NET Core Middleware, Pipeline & I have built a knockoff | Build a Library with me - VIII](https://i.ytimg.com/vi/K9sBI9ZFxRA/default.jpg)
![How IDisposable, Dispose, and Finalizers work in C#](https://i.ytimg.com/vi/e0G5X3bu6hY/default.jpg)
![.NET Core Garbage Collection](https://i.ytimg.com/vi/BeuNvhd1L_g/default.jpg)
![Application State in Blazor Apps](https://i.ytimg.com/vi/GIupo55GTro/default.jpg)
![Repository Pattern with C# and Entity Framework, Done Right | Mosh](https://i.ytimg.com/vi/rtXpYpZdOzM/default.jpg)