4.8. StarPrintPortJobMonitor

Monitor printer driver jobs

Important

This class can be used when printing via a printer driver.

  • Constructor

    Name Contents
    StarPrintPortJobMonitor Creates the StarPrintPortJobMonitor object.
  • Property

    Name Contents
    PortName This method gets the port name specified by the constructor.
    JobCount Gets the number of jobs in the printer queue that is associated with the printer port.
    PrintQueues Gets the “PrinterQueue” object array that is associated with the printer port.
  • Method

    Name Contents
    Start Starts job monitoring for the printer queue that is associated with the printer port.
    Stop Stops job monitoring for the printer queue that is associated with the printer port.
  • Event

    Name Contents
    PrintQueueJobIsAdded Occurs when a job is added to the printer queue that is associated with the printer port.
    PrintQueueJobIsRemoved Occurs when the number of jobs in the printer queue that is associated with the printer port is reduced.
    PrintQueueAllJobsAreCompleted Occurs when all jobs in the printer queue that is associated with the printer port have disappeared.

4.8.1. StarPrintPortJobMonitor

Create StarPrintPortJobMonitor object.

  • Declaration

    public StarPrintPortJobMonitor(string portName)
    
  • Parameter

    Name Contents Type
    portName
    Printer port name of printer queue
    It is the same as the portName of the GetPort method.
    string
  • Return value

    Contents Type
    StarPrintPortJobMonitor object StarPrintPortJobMonitor
  • Examples

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    

    Refer to PrinterDriverWithCheckStatusSamplePage.xaml.cs/ PrinterDriverWithBarcodeReaderSamplePage.xaml.cs/ PrinterDriverWithDisplaySamplePage.xaml.cs.

4.8.2. PortName

This method gets the port name specified by the constructor.

  • Declaration

    public string PortName { get; }
    

4.8.3. JobCount

Gets the number of jobs in the printer queue that is associated with the printer port.

  • Declaration

    public int JobCount { get; }
    

4.8.4. PrintQueues

Gets the “PrinterQueue” object array that is associated with the printer port.

  • Declaration

    public PrintQueue[] PrintQueues{ get; }
    

4.8.5. Start

Starts job monitoring for the printer queue that is associated with the printer port.

  • Declaration

    public bool Start()
    
  • Parameter

    None

  • Return value

    Contents Type
    true … Success
    false … Failure
    bool
  • Examples

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    

    Refer to PrinterDriverWithCheckStatusSamplePage.xaml.cs/ PrinterDriverWithBarcodeReaderSamplePage.xaml.cs/ PrinterDriverWithDisplaySamplePage.xaml.cs.

4.8.6. Stop

Stops job monitoring for the printer queue that is associated with the printer port.

  • Declaration

    public bool Stop()
    
  • Parameter

    None

  • Return value

    Contents Type
    true … Success
    false … Failure
    bool
  • Examples

    private void Page_Unloaded(object sender, RoutedEventArgs e)
    {
        starPrintPortJobMonitor.Stop();
    }
    

    Refer to PrinterDriverWithCheckStatusSamplePage.xaml.cs/ PrinterDriverWithBarcodeReaderSamplePage.xaml.cs/ PrinterDriverWithDisplaySamplePage.xaml.cs.

4.8.7. PrintQueueJobIsAdded

Occurs when a job is added to the printer queue that is associated with the printer port.

  • Declaration

    public event EventHandler PrintQueueJobIsAdded
    
  • Examples

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    
    private void OnPrintQueueJobIsAdded(object sender, object e)
    {
        PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    }
    

    Refer to PrinterDriverWithCheckStatusSamplePage.xaml.cs/ PrinterDriverWithBarcodeReaderSamplePage.xaml.cs/ PrinterDriverWithDisplaySamplePage.xaml.cs.

4.8.8. PrintQueueJobIsRemoved

Occurs when the number of jobs in the printer queue that is associated with the printer port is reduced.

  • Declaration

    public event EventHandler PrintQueueJobIsRemoved
    
  • Examples

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    
    private void OnPrintQueueJobIsRemoved(object sender, object e)
    {
        PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    }
    

    Refer to PrinterDriverWithCheckStatusSamplePage.xaml.cs/ PrinterDriverWithBarcodeReaderSamplePage.xaml.cs/ PrinterDriverWithDisplaySamplePage.xaml.cs.

4.8.9. PrintQueueAllJobsAreCompleted

Occurs when all jobs in the printer queue that is associated with the printer port have disappeared.

  • Declaration

    public event EventHandler PrintQueueAllJobsAreCompleted
    
  • Examples

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    
    private void OnPrintQueueAllJobsAreCompleted(object sender, object e)
    {
        PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
        IPort port = Factory.I.GetPort("BT:COM1", "", 10000);
    }
    

    Refer to PrinterDriverWithCheckStatusSamplePage.xaml.cs/ PrinterDriverWithBarcodeReaderSamplePage.xaml.cs/ PrinterDriverWithDisplaySamplePage.xaml.cs.