This is a migrated thread and some comments may be shown as answers.

Cancel Report Generation

1 Answer 213 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 11 Jan 2018, 01:58 PM

Is there anyway to cancel a report being generated with RenderReport?  For example, we are creating a PDF of a report that takes some time to finish.  Is there any asynchronous ways of creating the report such that we can cancel its execution? 

 

I saw a post on here a few years ago that it couldn't be canceled, but I'm hoping something has been done since then to change this.  Thanks for any guidance.

Example:

ReportProcessor reportProcessor = new ReportProcessor();                      

ReportLibrary.TestReport report = new ReportLibrary.TestReport();                                               InstanceReportSource reportSource = new InstanceReportSource();                         

reportSource.ReportDocument = report;                         

RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, null);

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 16 Jan 2018, 10:28 AM
Hi Paul,

Currently, the generation of a report cannot be cancelled.

A possible workaround is to run the ReportProcessor in a separate thread, and kill the thread based on some custom condition (i.e. after some time).

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Ashish Kumar
Top achievements
Rank 1
commented on 07 Sep 2024, 07:30 AM

Is it true for this RenderReport method as well ?

https://docs.telerik.com/reporting/api/telerik.reporting.processing.reportprocessor#Telerik_Reporting_Processing_ReportProcessor_RenderReport_System_String_Telerik_Reporting_ReportSource_System_Collections_Hashtable_Telerik_Reporting_Processing_CreateStream_System_Threading_CancellationToken_System_String__

As this RenderReport method accepts the CancellationToken and this is the description of that parameter

A CancellationToken instance that allows to cancel the current rendering.

We are providing user with scheduled download of the Report if data is huge, and we are currently using this method

https://docs.telerik.com/reporting/api/telerik.reporting.processing.reportprocessor#Telerik_Reporting_Processing_ReportProcessor_RenderReport_System_String_Telerik_Reporting_ReportSource_System_Collections_Hashtable_Telerik_Reporting_Processing_CreateStream_System_String__

And wrapping this in Task.Run and kill the thread after 10 mins, if still not completed, but killing the thread is causing instability sometime, it is brining down the complete WebJob itself.

Hence, was thinking of switching to the method which accepts CancellationToken, but before that wanted to confirm the behaviour.

Todor
Telerik team
commented on 10 Sep 2024, 11:44 AM

Hello Ashish,

I confirm that you may use the method RenderReport(String, ReportSource, Hashtable, CreateStream, CancellationToken, out String).

The CancellationToken was introduced with R2 2020 (14.1.20.513) and lets you cancel the current report rendering. Note that the thread was opened in 2018 when the CancellationToken was not available.

You may also attach a Trace Listener to your application (Troubleshooting Reporting Implementation Into ASP.NET Core Application) to check the exact cause for the failure and try to fix it.

Tags
General Discussions
Asked by
Paul
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or