New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncLazy blocks thread until concurrent factory returns asynchronously #243
Comments
Are you using |
Sorry, it's been a while, but yes - I'd tried both. I don't control the factories - they might be synchronously heavy or not. In the quickly-async case i didn't want the overhead of
|
This is my take on it - none of your options are implemented (as I haven't needed them).
|
I've experienced thread starvation in these cases (using AsyncLazy to populate entries in MemoryCache).
It's only an issue with factory methods which have a long CPU bound lead-in before their first "await", and are not explicitly started on thread pool. (In my use case, I can't predict these cases, and I prefer to avoid the thread overhead.)
To resolve, I made my own AsyncLazy using SemaphoreSlim instead of lock.
I'd much prefer to use a reputable nuget, though😊.
The text was updated successfully, but these errors were encountered: