Cancel report in html viewer

We have an MVC web application using LL21 where you can view reports in the browser and edit them with the web designer. A typical pattern is to have the designer and browser open at the same time, edit the report in the designer, and refresh the report in the browser to see the changes.

If the report is large, with many pages, and if you refresh the browser frequently enough, we’re seeing the server CPU spike and the app can stop responding. We assume when the report is refreshed, the original one is still running (paginating) in memory. If you refresh fast enough there are probably many old reports running to completion simultaneously.

It seems like the proper solution would be to cancel a running report if it is re-run, but we don’t see a way to do this in code. Is it possible?

We figured this out. The key is to keep a reference to the ListLabel object created for the viewer in the Html5ViewerConfig.OnListLabelRequest event. To cancel the report while it’s running, call LL.Core.LlPrintAbort() on that instance. You should also hook up a listener to the instance’s PrintingFinished event, which fires when the report is finished running. After that, it’s no longer necessary to cancel the report, so it’s safe to dispose of the saved instance.