你的位置: 码友网首页 / 资讯源列表 / Thread Safety & Scoped Lifetime in Dependency Injection Containers

关于[Thread Safety & Scoped Lifetime in Dependency Injection Containers]的摘要:

If you’re using Scoped Lifetime in a Dependency Injection containers, beware! You may be run into race conditions due to a lack of thread safety. I was doing a live stream on Domain Events over on my YouTube Channel where I was taking advantage of Scoped Lifetime. After the stream, I realized Scoped Lifetime and thread safety isn’t mentioned much and I’m not sure why? It could be because developers aren’t using multiple threads within the top-level request (HTTP request or service bus message invocation). Or it’s because developers are writing thread-safe code by default. I tend to think it’s the former. Either way, I figured it would be worthwhile providing an example of using Scoped Lifetime and how you can run into issues if you aren’t writing thread-safe code.

原文地址: https://codeopinion.com/thread-safety-scoped-lifetime-in-dependency-injection-containers/

收录时间: 2020-07-16 浏览量: 1472 分类: .NET Core

| 0 收藏 | 0