Skip to content
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

.net core webApi 起线程时使用AspectCore,抛出ObjectDisposedException #275

Open
KhalidDu opened this issue Oct 26, 2021 · 1 comment

Comments

@KhalidDu
Copy link

KhalidDu commented Oct 26, 2021

在.net core 3.1 中,我有一个启用事务的特性, 使用Autofac管理容器, 当我有一个Api场景, 需要及时的返回结果, 故, 我在Api被调用时, 启用了一个线程, 此时, 启用事务的特性被标记在接口上, 并在线程中被调用, 当我调用接口时(测试可以使用threade.sleep(10000)),当接口返回成功是, 继续执行线程中的内容时, 会抛出objectDisposedException, 我检查了好久的代码, 才找到问题, 当我去掉特性时, 一切又恢复了正常

@liuhaoyang
Copy link
Member

在接口返回的时候,AspectContext已经关闭了。后台的线程又去调用了打了拦截器特性的函数..再尝试访问AspectContext就报错了。。。这个问题在AspectCore中可以尝试修复一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants