首页 新闻 会员 周边 捐助

.net core执行 Task.Run问题

0
悬赏园豆:5 [待解决问题]

我在本地执行 Task.Run完全没有问题,但是当我部署到服务器上时,发现没有效果,于是我用log记录操作日志,但是只能记录到图片里面的LogInfo,对于 _eventBus.RaiseEvent(reviewEvent)却没反应,并且也没有捕获到异常,是什么原因?

问题补充:

已经知道大概原因了,因为在开始已经使用了 _eventBus.Publish(command),里面异步调用了 _eventBus.RaiseEvent(reviewEvent),可能是_eventBus.Publish先结束,释放了eventBus。但是两个是在不同的类里面,并且不同的构造函数注入的。

灬丶的主页 灬丶 | 初学一级 | 园豆:3
提问于:2020-06-24 10:00
< >
分享
所有回答(1)
0

_eventBus.RaiseEvent(reviewEvent)这个方法里是否有日志?可以看看执行效果

会长 | 园豆:12463 (专家六级) | 2020-06-24 10:11

我刚加了日志从新执行了下,奇怪,我本地都没有错误,我看看什么原因
Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
at Blog.Domain.Core.Bus.EventBus.RaiseEvent[TEventData](TEventData eventData)

支持(0) 反对(0) 灬丶 | 园豆:3 (初学一级) | 2020-06-24 10:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册