I am having the console application which creates the PDF for a set of records. For if the count is 9000 above an error occurred that "Error creating window Handle". In the application level i am using 6 threads.
As i observed in the Task Manager the Handles are increasing and the user objects are also increasing.
I have written the obj.Dispose method where ever i have created the object. So now my question is how to decrease the user objects and Handles.
I am using the console application with 3.5 Framework in C#.
Update:
Below is the code which i have used
Thread FirstTreadPDFs = new Thread(() => objPDFsProcess.DoGeneratePDFsProcess());
FirstTreadPDFs.Start();
//Thread2 Thread SecondTreadPDFs = new Thread(() => objPDFsProcess.DoGeneratePDFsProcess()); SecondTreadPDFs.Start();
//Thread3 Thread ThirdTreadPDFs = new Thread(() => objPDFsProcess.DoGeneratePDFsProcess2()); ThirdTreadPDFs.Start();
//Thread4 Thread FourthTreadPDFs = new Thread(() => objPDFsProcess.DoGeneratePDFsProcess()); FourthTreadPDFs.Start();
//Thread5 Thread FifthTreadPDFs = new Thread(() => objPDFsProcess.DoGeneratePDFsProcess1()); FifthTreadPDFs.Start();
FirstTreadPDFs.Join(); SecondTreadPDFs.Join(); ThirdTreadPDFs.Join(); FourthTreadPDFs.Join(); FifthTreadPDFs.Join();
DataSet dsHeader1 = new DataSet();
//Pending Cusotmers need to get to generate PDFs
dsHeader1 = objCustStatementDAL.GetCustStatementdetailsForPDF(IsEDelivery, 1);
if (dsHeader1 != null && dsHeader1.Tables.Count > 0)
{
if (dsHeader1.Tables[0].Rows.Count > 0)
{
writerLog.WriteLine(DateTime.Now + " Trying to get Pending Records");
objPDFsProcess.DoGeneratePDFsProcess2();
writerLog.WriteLine(DateTime.Now + " Exit Trying to get Pending Records block");
}
}
dsHeader1.Dispose();
After executing 9000+ records the Exit Trying line is executing and stopping the application.
Where ever i use the object i placed Dispose method.