Reputation: 9
I have an WPF application that collects and prints multiple pdf files in a specific order to a online printer. The problem is that it is taking very long time, one page takes about 10sec and the full process is up to 10min.
I have tried to start all tasks and then await Task.WhenAll but then it doesnt get in the order i have created and started the task due to some files bigger than others and gets completed and sent to printer before. I would like to start all printjobs (Printdocument) and before EndPrint event is triggered (gets sent to que) wait for tasks started earlier to finnish before next task in line can complete. Tried to listen to PagePrint event and when HasMorePages == false, await the task with index-1 but doesnt get it to work. Someone that have had an similar problem and have a solution for this?
foreach(var file in files)
PrintJob(file);
public static void PrintJob(File file)
{
var doc = file.PdfDocument.GetPrintDocument(SettingsPrinter.DefaultSettings);
doc.Print();
}
Upvotes: 0
Views: 71