当静态对象在Visual Studio中同时运行时,是否共享静态对象?如果是这样,如何预防?
虽然我认为将大型对象静态化是有效的,但我只是被告知应防止使用静态对象,因为在Visual Studio中,您无法控制哪些测试正在运行,并且测试可能会同时运行。这意味着可以同时访问和/或通过多个测试来访问静态对象。
有没有办法防止这种情况发生?我发现但似乎仅适用于字段变量。
While I was thinking it is is memory efficient to make large objects static, I was just told that using static objects should be prevented because in Visual Studio you can't control which tests are running and tests might run simultaneously. Meaning that the static object could be accessed and/or manipulated by multiple tests at the same time.
Is there a way to prevent that from happening? I found ThreadStaticAttribute but it seems to only work for field variables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论