Hello my app has a button to print listed documents. The list can be quite long, like 1000 documents.
PrintDialog printDialog = new PrintDialog();
DialogResult dialogResult = printDialog.ShowDialog();
if (dialogResult == DialogResult.OK)
{
foreach (Datei datei in dateienList)
{
if (datei.dateiAuswählen == true)
{
PrinterSettings currentPrinterSettings = new PrinterSettings();
printDialog.PrinterSettings = currentPrinterSettings;
currentPrinterSettings.Copies = (short)datei.anzahlKopien;
ProcessStartInfo processInfo = new ProcessStartInfo()
{
Verb = "print",
CreateNoWindow = true,
FileName = datei.pfad,
WindowStyle = ProcessWindowStyle.Hidden
};
Process process = new Process();
process.StartInfo = processInfo;
process.Start();
process.WaitForInputIdle();
process.WaitForExit();
System.Threading.Thread.Sleep(5000);
}
}
}
At first I set Thread.Sleep timeout to 3000, but listed documents got printed out in a mixed order. So, I set it to 60000, assuming it has too little time to process the documents, but it takes way too long since every single document has to be opened, processed, and then closed even though it's set to be invisible.
Is there any solution to this problem? Or should I try another method to print out documents?