Forum Discussion
Singleton Class with Async
I'm working on building a Blazor Web App (.net 9) for an internal company portal.
I want to load some persistent data to be used throughout the app into a class and then load that class as a scoped service.
Most of the data will be fairly static, but expensive data to retrieve, ie: graph api call for members of groups, etc. So that data will also be loaded asynchronously.
Everything I've found regarding loading data into a class asynchronously basically points back to a post by Stephen Cleary on Asynchronous Lazy Initialization: https://blog.stephencleary.com/2012/08/asynchronous-lazy-initialization.html
My question is, given that this post was originally posted back in 2012, is this still an acceptable way of loading data asynchronously for a singleton or are there other, more modern approaches to this scenario?