0

When I have two instances of a PrintQueue in C#, of the same printer. One I made before I called .refresh(), the other after. I put those PrintQueues in a ArrayList. And rotate them. Yet I get different results, like so:

if(arrPrintersOld != null)
{
    arrPrintersOld.Clear();
    arrPrintersOld = null;
}

arrPrintersOld = arrPrinters;

arrPrinters = new ArrayList();

        PrintQueueCollection printQueues = null;

        // PrintServer Class = Manages the print queues on a print server, 
        // which is usually a computer, but can be a dedicated hardware print server appliance.
        PrintServer printServer = new PrintServer();

        printQueues = printServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });

        foreach (PrintQueue pq in printQueues)
        {

            pq.Refresh();

            arrPrinters.Add(pq);
        }

        if(!blnFirstTimePrinterList)
        {
            comparePrinterLists();

            PrintQueue tempOld = (PrintQueue)arrPrintersOld[0];
            PrintQueue tempNew = (PrintQueue)arrPrinters[0];

            Console.WriteLine("OldPrinter 1 is paused:" + tempOld.IsPaused);
            Console.WriteLine("NewPrinter 1 is paused:" + tempNew.IsPaused);
        }

Once I unpause the printer, I get an true at the tempOld.IsPaused, and a false at tempNew.IsPaused;

But when I get pause the printer again, I get a true and tempOld.IsPaused and a true and TempNew.IsPaused?

So does the refresh() function also work at the told instances of am I missing something?

halfer
  • 19,824
  • 17
  • 99
  • 186
Michiel Krol
  • 243
  • 3
  • 9
  • We need to see some code on how you pause, unpause the printer, if its done from code. – Athanasios Kataras Jan 06 '20 at 14:39
  • No I unpause/pause it in Windows (configuration panel) – Michiel Krol Jan 06 '20 at 15:30
  • System.Printing is an extremely troublesome namespace. Skipped for the .NET 2.0 release because of quality issues, they couldn't skip it again for 3.0 because WPF took a dependency on it. Omitted from the reference source, it will not be added to .NETCore. I *think* the wonky rule is that Refresh() will only refresh properties that you used before. Do what works, keep fingers crossed. – Hans Passant Jan 06 '20 at 15:46

0 Answers0