-1

I do not know how to do it. There are two printers. They need to print documents at the same time. Actually the algorithm can be; If you are printing something on the system, the two printers reprint this document.

foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
    if (printer == "ZJ-58")
    {

    }

    if (printer == "ZJ-58-2")
    {

    }
}
Til
  • 5,150
  • 13
  • 26
  • 34
ea.unix
  • 9
  • 2
  • I would first start with printing using C#, then try to print to multiple printers. This might help: https://stackoverflow.com/questions/20692697/how-to-print-a-document-using-c-sharp-code – Jimenemex May 29 '19 at 18:33
  • To start with, define "same time". Also, in your code, use `||` and have just one `if` so you don't repeat the printing code. – NetMage May 29 '19 at 18:35

1 Answers1

-2

If you want to trigger the printing at the same time you could fire tasks in parallel (here I'm assuming you have a print function which returns a task). Eg:

var printers = new List<object>();
var printerTasks = printers.Select(printer =>
{
     if (printer == "ZJ-58")
     {
          return printer.print();
     }

     if (printer == "ZJ-58-2")
     {
          return printer.print();
     }
 });
 Task.WaitAll(printerTasks);
Yann Thibodeau
  • 1,111
  • 1
  • 12
  • 20
  • 1
    I downvoted this because the statement *here I'm assuming you have a print function which returns a task* is a bad assumption. There's no indication in the question that this is the case, and if it's *not* the case, your answer is wrong. – Daniel Mann May 29 '19 at 20:11
  • Thanks for the answer. But what I'm looking for is triggering printers when any printing is done on the computer. – ea.unix May 29 '19 at 20:24
  • 1
    Yeah, I should have asked for clarifications instead of blindly throwing help. – Yann Thibodeau May 29 '19 at 20:26