Life-cycle of AsyncLocal instances in Blazor Server Side Middleware

Viewed 59

I'd like to know how AsyncLocal save state between http requests in Blazor Server. Is it one hundred percent threadsafe? And can I be sure that if I put the value in AsyncLocal in one HttpContext I won't be able to overwrite it from the same thread but another HttpContext?

1 Answers

how AsyncLocal save state between http requests

It doesn't. AsyncLocal lets you store values in an (1) async call-chain. It keeps the value over an await, that's about all.

Each HttpRequest will have its own AsyncLocals, totally separated. And yes, that is thread-safe.

Related