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

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

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

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

شما ازین روش استفاده میکنید؟
👍215👌2



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: |

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. Judge Hui described Ng as inciting others to “commit a massacre” with three posts teaching people to make “toxic chlorine gas bombs,” target police stations, police quarters and the city’s metro stations. This offence was “rather serious,” the court said. Clear Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the “Yo” app was launched with the sole purpose of enabling users to send each other the greeting “Yo.” So far, more than a dozen different members have contributed to the group, posting voice notes of themselves screaming, yelling, groaning, and wailing in various pitches and rhythms.
from us


Telegram .NET Internals
FROM American