PrintQueue.Refresh Method ()

 

Updates the properties of the PrintQueue object with values from the printer and the print queue utility that runs on the computer.

Namespace:   System.Printing
Assembly:  System.Printing (in System.Printing.dll)

public override void Refresh()

Exception Condition
PrintSystemException

Some of the properties could not be refreshed.

Changes your program makes to a PrintQueue object's properties are lost when Refresh executes, unless they have been written to the printer and print queue with Commit.

The following example shows how to use this method as part of a survey all printers for possible error status.

// Survey queue status for every queue on every print server
String line;
String statusReport = "\n\nAny problem states are indicated below:\n\n";
while ((line = fileOfPrintServers.ReadLine()) != null)
 {
     PrintServer myPS = new PrintServer(line, PrintSystemDesiredAccess.AdministrateServer);
     PrintQueueCollection myPrintQueues = myPS.GetPrintQueues();
     statusReport = statusReport + "\n" + line;
     foreach (PrintQueue pq in myPrintQueues)
     {
         pq.Refresh();
         statusReport = statusReport + "\n\t" + pq.Name + ":";
         if (useAttributesResponse == "y")
         {
             TroubleSpotter.SpotTroubleUsingQueueAttributes(ref statusReport, pq);
             // TroubleSpotter class is defined in the complete example.
         }
         else
         {
             TroubleSpotter.SpotTroubleUsingProperties(ref statusReport, pq);
         }                 

     }// end for each print queue

 }// end while list of print servers is not yet exhausted

fileOfPrintServers.Close();
Console.WriteLine(statusReport);
Console.WriteLine("\nPress Return to continue.");
Console.ReadLine();

.NET Framework
Available since 3.0
Return to top
Show: