MVC ControllerContext,线程/任务,Rotativa [英] MVC ControllerContext, Threads/Tasks, Rotativa

查看:497
本文介绍了MVC ControllerContext,线程/任务,Rotativa的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rotativa 1.6.4保持在发行Rotativa.dll System.NullReferenceException

Rotativa 1.6.4 keeps issuing System.NullReferenceException in Rotativa.dll

特别是,它发生在BuildPdf(上下文)

Specifically it occurs on BuildPdf(context)

我都试过主题,任务和其他背景类型的工作。为什么? PDF生成是在时间和使用越野车ActionAsPdf极其缓慢(见这里),所以我想旋转它开了一个新的线程/任务或后台作业,只记录错误,这样我就可以得到用户回到尽快赶路。

I have tried Thread, Task and other background type jobs. Why? The PDF generation is extremely slow at times and buggy using ActionAsPdf (see Here) so I want to spin it off to a new thread/task or background job, and only log errors, so I can get the user back on their way asap.

该BuildPdf接受当前控制器上下文,它总是会在空我试着做一个新的环境,使用的HttpContext,使得控制器的一个新实例所有相同的结果。一旦它进入了Rotativa.dll的背景下compeltely走了,不管我在从我作为线程/任务面前经过,或创建之前,我打电话BuildPdf(新);

The BuildPdf takes the current controller context, which always is going in null I've tried making a new context, using httpcontext, making a new instance of controller all with same results. Once it gets into the Rotativa.dll the context is compeltely gone, no matter if I pass it in from before I being the Thread/Task, or create a new one right before I call BuildPdf();

我如何从获得一个有效的控制器上下文无论是之前,我开始线程/任务的工作,否则一旦线程/任务的工作往里进Rotativa?

How do I get a valid controller context from either before I begin the thread/task job, or once inside the thread/task job into Rotativa?

在这一点上,我比准备花费真金白银一个真正的PDF解决方案的更多,但到目前为止,似乎他们都是PITA,即使你有PDF的最简单的孩子的需求仅仅是平庸的最好的。

At this point I'm more than ready to spend real money on a real PDF solution, but so far it seems they all are PITA and are only mediocre at best even if you have the most simplistic child needs of PDF.

推荐答案

你有没有尝试创建一个的SynchronizationContext 呢?

Did you try to create a SynchronizationContext instead?

好像库非线程安全的。

这篇关于MVC ControllerContext,线程/任务,Rotativa的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆