This example shows how to render several reports in the thread. Since the render reports in the thread run the background, it provides an opportunity to increase productivity. For this purpose the BackgroundWorker class is used. For simplicity, the same report is run to build in five different threads:
private void button2_Click(object sender, EventArgs e)
{
	for (int index = 0; index < 5; index++)
	{
		var worker = new BackgroundWorker();
		worker.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
		worker.RunWorkerAsync();
	}
}

In the start of the backgroundWorker2_DoWork() event process you can load the report and connect data. Also, if it is necessary, you can subscribe to some events. In ther end, compile and render the report:
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
	var report = new StiReport();
	using (var stream = Assembly.GetExecutingAssembly().
		GetManifestResourceStream("RenderInThread.MasterDetailSubdetail.mrt"))
	{
		report.Load(stream);
	}

	report.IsRendered = false;
	report.EndRender += new EventHandler(ReportTemplate_EndRender);
	report.Render(false);
}

In the screenshot below you can see the result of the sample code:

Rendering Several Reports in the Thread

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.