Quantcast
Viewing all articles
Browse latest Browse all 3636

Is the ReportDocument class thread safe?

Hi there,

 

I'm using the ReportDocument class (in CrystalDecisions.CrystalReports.Engine namespace) for generating the reports to PDF files base on the report templates prepared by CR2011. Due to the performance issue, I employed multi-thread approach to use different ReportDocument objects simultaneously in order to speed up the large number of reports generation. The following is my calling sequence on each thread:

 

 

ReportDocument crReportDoc = new ReportDocument();

crReportDoc.Load(templName);

crReportDoc.SetParameterValue(crParam.name, crParam.value);

 

DataSourceConnections dataSourceConnections = crReportDoc.DataSourceConnections;

IConnectionInfo connectInfo = dataSourceConnections[0];

connectInfo.SetConnection(m_crDBServer, m_crDBName, true);

 

crReportDoc.ExportToDisk(ExportFormatType.PortableDocFormat, outpName);

crReportDoc.Close();

crReportDoc.Dispose();

 

 

This approach seems woking fine with me and I tested to spawn upto four threads (by using ThreadPool.QueueUserWorkItem()) for executing the above code segment simultaneously without any problem. Does that means the ReportDocument class is thread safe? As we are going to launch the product soon, so want to have a confirmation that this usage is OK. Thanks in advance.

 

Cheers,

Elliott

 

PS: I'm using SAP Crystal Reports, developer version for Microsoft Visual Studio version 13.x Library and VS2005 for the development, and the target running environment is on Win2003Svr Enterprise.


Viewing all articles
Browse latest Browse all 3636

Trending Articles