Asynchronous calls

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF PrintManager for .NET (v1)  /  Asynchronous calls

DynamicPDF PrintManager for .NET (v1) Forum

 Aug 18 2009 6:14 AM
Hi,

Is there a way to make calls to the printer asynchronous? We are finding that the PDF printmanager is slow to complete the print job method, e.g. it send's the job to the printer, waits for it to spool and then print before returning control back to the application that made the call.

thanks,

Paul
 Aug 18 2009 9:37 AM
Posted by a ceTe Software moderator
Hello Paul,

Currently it is not possible to do asynchronous printing directly using the API. This is a feature we do have on our wish list and will be added in the near future in the coming version.

Currently you will have to use Threads to do the asynchronous printing.

Thanks,
ceTe Software Support Team.
 Apr 25 2023 1:49 PM
Regarding  "use Threads to do the asynchronous printing."
Can it be done using async Task like

static async Task Main(string[] args)
{
             var aTaskA= PrintAsync("DocumentA.pdf");
            var aTaskB= PrintAsync("DocumentB.pdf");
            var printTasks = new List<Task> { aTaskA, aTaskB};
            while (printTasks .Count > 0)
            {
                Task finishedTask = await Task.WhenAny(breakfastTasks);
                if (finishedTask == aTaskA)
                {
                    Console.WriteLine("aTaskA are ready");
                }
                else if (finishedTask == aTaskB)
                {
                    Console.WriteLine("aTaskBis ready");
                }
                await finishedTask;
                breakfastTasks.Remove(finishedTask);
            }
}

static async Task PrintAsync(string doc)
        {
            byte[] pdfBytes = System.IO.File.ReadAllBytes(doc);
 
           InputPdf pdf = new InputPdf(pdfBytes);
          PrintJob printJob = new PrintJob(Printer.Default, pdf);
 
           printJob.Print();
        }
 Apr 28 2023 12:38 PM
Posted by a ceTe Software moderator
Hi,

Yes, that will work fine to make the call asynchronous.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 12:55 PM.