6K Star 11.8K Fork 4K

GVPdotNET China / Furion

 / 详情

定时任务使用Scope.CreateUnitOfWork引发的问题

已完成
创建于  
2021-04-25 16:33

Furion 版本号

哪个版本号?
2.1.0

Web 项目类型

  • WebApi

描述你的问题

定时任务本来我用的都是CreateWork 现在都换成了CreateUnitOfWork 。这个时候就会报错如下
System. objectDisposed Exception:"Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling ' Disp he contex止t g statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instance


代码或代码仓库

举例:
A服务.1方法 三秒执行一次,更新数据库
A服务.2方法 5秒执行一次,更新数据库
都使用定时任务,通过Scope.CreateUnitofWork 创建A服务,在执行savechanges的时候会报错,是因为创建出来的是同一个还是说EF上下文相同


数据库信息

  • PGSql

期待结果

期待的结果是?
定时任务使用CreateUnifOfWork可以让saveChanges正常执行,而不是使用一个相同的上下文。


评论 (2)

happlyfox 创建了任务
happlyfox 关联仓库设置为dotNET China/Furion
展开全部操作日志

这样的 Issue 没有任何价值。代码没有给出,详细的错误堆栈没给出。

百小僧 修改了描述
百小僧 任务状态待办的 修改为进行中
百小僧 负责人设置为百小僧
百小僧 添加了
 
疑问
标签
百小僧 里程碑设置为Furion 2021
百小僧 关联分支设置为master
百小僧 计划截止日期设置为2021-04-25
百小僧 计划开始日期设置为2021-04-25

经过测试,并无发现 Furion 框架问题,建议升级到最新版再测试。

百小僧 通过 dotnetchina/Furion Commit 9be4c7f任务状态进行中 修改为已完成
百小僧 关联分支master 修改为未关联

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
974299 monksoul 1578937227 5606183 happlyfox 1591511140
C#
1
https://gitee.com/dotnetchina/Furion.git
git@gitee.com:dotnetchina/Furion.git
dotnetchina
Furion
Furion

搜索帮助