DOTNET_INTERNALS Telegram 7
درمورد DependencyInjection یکی از نکاتی که کمتر میبینم بهش توجه میشه اینه اگر شما یه شئ رو در زمان ریجستر کردن ایجاد کنید دیگه DI کنترلی روی ایجاد و حذفش نداره و این مسئولیت برنامه نویس هست که منابعی رو که توی اون کلاس استفاده میشه رو آزاد کنه.

نکته بد ماجرا اینجا شروع میشه که اگر از این روش برای AddScope استفاده بشه به ازای هر درخواست یه شئ ایجاد میشه و منابع آزاد نمیشه و بقیه ماجرا که خودتون بهتر میدونید!

بهترین روش اینه که بذارید خود DI کارشو انجام بده و اینجوری باید استفاده بشه:
builder.Services.AddSingleton<Service1>();

و درمورد خاص که راهی وجود نداره حتما اینترفیس IDisposable رو پیاده کنید.

شما ازین روش استفاده میکنید؟



tgoop.com/dotnet_internals/7
Create:
Last Update:

درمورد DependencyInjection یکی از نکاتی که کمتر میبینم بهش توجه میشه اینه اگر شما یه شئ رو در زمان ریجستر کردن ایجاد کنید دیگه DI کنترلی روی ایجاد و حذفش نداره و این مسئولیت برنامه نویس هست که منابعی رو که توی اون کلاس استفاده میشه رو آزاد کنه.

نکته بد ماجرا اینجا شروع میشه که اگر از این روش برای AddScope استفاده بشه به ازای هر درخواست یه شئ ایجاد میشه و منابع آزاد نمیشه و بقیه ماجرا که خودتون بهتر میدونید!

بهترین روش اینه که بذارید خود DI کارشو انجام بده و اینجوری باید استفاده بشه:
builder.Services.AddSingleton<Service1>();

و درمورد خاص که راهی وجود نداره حتما اینترفیس IDisposable رو پیاده کنید.

شما ازین روش استفاده میکنید؟

BY .NET Internals




Share with your friend now:
tgoop.com/dotnet_internals/7

View MORE
Open in Telegram


Telegram News

Date: |

On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression." Matt Hussey, editorial director at NEAR Protocol also responded to this news with “#meIRL”. Just as you search “Bear Market Screaming” in Telegram, you will see a Pepe frog yelling as the group’s featured image. Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them. Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day. Hashtags
from us


Telegram .NET Internals
FROM American