文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】在線程中呈現(xiàn)多個(gè)報(bào)表
【Stimulsoft Reports.WinForms教程】在線程中呈現(xiàn)多個(gè)報(bào)表
【下載Stimulsoft Reports.Ultimate最新版本】
此示例顯示如何在線程中呈現(xiàn)多個(gè)報(bào)表。由于線程中的渲染報(bào)表運(yùn)行后臺,因此它提供了提高生產(chǎn)率的機(jī)會。為此,使用BackgroundWorker類。為簡單起見,運(yùn)行相同的報(bào)表以構(gòu)建五個(gè)不同的線程:
private void button1_Click(object sender, EventArgs e) { for (int index = 0; index < 5; index++) { var worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); worker.RunWorkerAsync(); } }
在backgroundWorker1_DoWork事件過程的開始,您可以加載報(bào)表并連接數(shù)據(jù)。此外,如果有必要,您可以訂閱一些活動。最后,編譯并呈現(xiàn)報(bào)表:
... private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { var report = new StiReport(); using (var stream = Assembly.GetExecutingAssembly(). GetManifestResourceStream("RenderInThread2.Master-Detail-Subdetail.mrt")) { report.Load(stream); } DataSet data = new DataSet(); data.ReadXmlSchema("..\\..\\Data\\demo.xsd"); data.ReadXml("..\\..\\Data\\demo.xml"); report.RegData(data); report.IsRendered = false; report.Compile(); report.Render(false); }
購買Stimulsoft正版授權(quán),請點(diǎn)擊“咨詢在線客服”喲!