Reputation: 5620
I am generating 1000's of PDFs from crystal report. Generating PDF one by one(sequentially) takes time which degrades performance. To improve performance i am using ThreadPooling which is generating PDFs much faster way but when the PDF generation completes. My webpage controls dont fire events i.e i have a radio button(autopostback=true) so i should fire an event when onchange event occurs but i dont understand whats going wrong it doesnt raise the event? Am i using threadpool in asp.net wrong way or is there any other class available which works same as threadpool?
dynamic obj = new { strvalue = strvalue, SimulActual = SimulActual, IsCrewRPT = IsCrewRPT, rowcount = rowcount, FileName = FileName, RankP = RankP, RankCDP = RankCDP, intRowNo = intRowNo, rpt = rpt, ToYear = ToYear, Cdc_no = Cdc_no, TotalPDF = TotalPDF, TotalRowcount1 = TotalRowcount1 };
ThreadPool.QueueUserWorkItem(new WaitCallback(PDFActualOffThreadWithPanCard), obj);
ThreadPool.SetMaxThreads(10, 5);
obj = null;
Upvotes: 0
Views: 73
Reputation: 51329
You should not rely on the thread pool in ASP.NET. There are a number of reasons for this. The main one is that ASP.NET can, and will, recycle the application pool servicing your page at any time, including between page requests, while your PDFs are generating. If that happens, your PDF generation will stop midway through.
The proper way to solve this problem is to offload the PDF generation request to something that is more controllable, usually a windows service (which can run on the same machine). A common technique is to use MSMQ or another persistent, transactional queue mechanism to control communication between the web server and a pool of PDF generator instances, potentially on multiple machines.
As for the problem of the postback, I think you need to provide a little more information about what is going on there for us to help you.
Upvotes: 1