Тёмный

Lazy Loading w/ System.Lazy (and async Lazy) - .NET ADVANCED ESSENTIALS 

SingletonSean
Подписаться 22 тыс.
Просмотров 8 тыс.
50% 1

Learn how to use the Lazy class in C# for lazy loading and initialization of resources. I also demonstrate a common use case where Lazy would be beneficial. I feel like no one talks about the Lazy class, but it's definitely useful to integrate as necessary.
TIMESTAMPS:
0:00 - Introduction
0:29 - Simple Demo Introduction
1:19 - Basic Lazy Functionality
2:56 - Lazy w/ Async Functions
5:08 - Advanced Demo Introduction
6:52 - Integrating Lazy
8:10 - Refreshing Lazy Initialized Data
9:34 - AsyncLazy Type
10:10 - Conclusion
FULL PLAYLIST: • .NET Advanced Essentials
OTHER LINKS:
Become a Member: / @singletonsean
Donations: www.paypal.com/biz/fund?id=UB...

Наука

Опубликовано:

 

23 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@simonlester4316
@simonlester4316 Год назад
Wow! super easily explained. Didn't know such functionality existed. Was using memory caching. Now this will become my default go-to. Thanks for this tutorial.
@WalwRafii
@WalwRafii 2 года назад
Great video, super easily explained, thank you!
@mehdizeynalov1062
@mehdizeynalov1062 Год назад
hi thanks very much for the video - just a note - i watched this video because of the thread safety issue - would be interesting to know on that more - what Lazy does differently for the thread safety. so overall if lazy has 2 advantages - one being "not eager" and second being thread safety - this needs a little bit of elaboration, and it's advantages to thread locks maybe - IMHO.
@Director414
@Director414 4 месяца назад
great video, many thanks!
@ariesduke2047
@ariesduke2047 3 года назад
man, I always did it with tasks and global variables before. I didn't even know such functionality existed. Thank you!
@SingletonSean
@SingletonSean 3 года назад
Thanks Aries! I used to fall in the trap of using Tasks as well.
@paulegan3783
@paulegan3783 3 года назад
Thanks! I'm still learning generics, tasks & async but this is great info.
@SingletonSean
@SingletonSean 3 года назад
Thanks Paul! Best of luck on your learning endeavors.
@DgreatRyan21
@DgreatRyan21 3 года назад
Can you create a simple CRUD app, with validation, error handling, with loading. (no api, no web services, etc.)
@SingletonSean
@SingletonSean 3 года назад
I think this is much-needed Ryan! My WPF "Full Stack" application covered some of these concepts, but like you mentioned, wasn't as simple as it should have been. I started recording a new series this week that is much simpler, so I'll see if I can fit these concepts into that application. Thanks for the suggestion!
@WahidRezgui
@WahidRezgui 3 года назад
Thanks a lot again another great and “crispy” content 😋
@SingletonSean
@SingletonSean 3 года назад
Thanks Wahid, very crispy!
@rS-lo6hw
@rS-lo6hw 3 года назад
Great explanation
@matthewbaier766
@matthewbaier766 2 года назад
This was an awesome video
@SingletonSean
@SingletonSean 2 года назад
Thanks Matthew!
@ivandrofly
@ivandrofly Год назад
9:37 Generic behind classes. Raw code also mentioned something similar in ru-vid.comFL0qKaumcxo
@ivandrofly
@ivandrofly Год назад
Stores with Lazy: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sScj_4xT8lY.html
@enriqueduquegarrido6132
@enriqueduquegarrido6132 2 года назад
A little note that has nothing to do with c # ... The subtitles for this video are set in Vietnamese.
@irrellevents
@irrellevents Год назад
Reasonable use of lazy, but unless I'm missing something, this is a waste of async. You should start an async task to get the account immediately after logging in, then not await it until the user needs it. That way, the user is presented with options immediately, but if they wait 3 seconds to do an action, the account is already ready for them.
@Christobanistan
@Christobanistan 3 года назад
A more interesting use of Lazy IMO is avoid initializing services as late as possible when you have interdependencies and don't want to maintain complex initialization code. For example, you have 20 services, each of which takes some set of dependencies on services in their constructors. Those change all the time and therefore would require rearranging initialization code for these services. Instead, have the constructors take Lazys, like (Lazy xb5, Lazy t2). The services will be hydrated only when they're necessary, and at the latest possible time so you don't have to worry about init code.
@SingletonSean
@SingletonSean 3 года назад
Good point, Christoban! That's a great use case for Lazy.
@Christobanistan
@Christobanistan 3 года назад
@@SingletonSean IME, it's almost essential with really large code bases!
Далее
Is It Okay To Put Properties on Interfaces?
3:14
Просмотров 2,8 тыс.
Elden Ring DLC - ПОДОЖГЛО ПОПУ!
07:26
Просмотров 472 тыс.
МЕГА ФОКУС С КАЛЬКУЛЯТОРОМ
00:33
8 await async mistakes that you SHOULD avoid in .NET
21:13
Implementing IEnumerable
17:35
Просмотров 10 тыс.
Writing C# without allocating ANY memory
19:36
Просмотров 145 тыс.
BEWARE! Async Lazy in C# Is Easy... But Is It Safe?
19:23
Is LEARNING WPF still WORTH it in 2023?
10:59
Просмотров 43 тыс.
Intro to Tuples in C# In 10 Minutes or Less
9:50
Просмотров 40 тыс.
But, what is Virtual Memory?
20:11
Просмотров 238 тыс.
Собираем комп за 500 000 рублей!
6:44:35
Здесь упор в процессор
18:02
Просмотров 387 тыс.