Does this library support pause- resume facility.

Oct 21, 2013 at 2:06 PM
I have a scenario here where i am monitoring a printer. What happens is when a job is added to a printer it is pause, and only resume after a user action.

OS what i have done is i have added the into a list view. Now i need to invoke a print job from the listview and resume it or delete it.

Prat of the code is below.

Public WithEvents pmon As New PrinterMonitorComponent
Private Delegate Sub AddListViewItemDelegate(ByVal lv As ListView, ByVal lvItem As ListViewItem)

Private Sub AddListViewItem(ByVal lv As ListView, ByVal lvItem As ListViewItem)

    If lv.InvokeRequired Then
        lv.Invoke(New AddListViewItemDelegate(AddressOf AddListViewItem), New Object() {lv, lvItem})
    Else
        lv.Items.Add(lvItem)
    End If

End Sub

Private Delegate Sub RemoveListViewItemDelegate(ByVal lv As ListView, ByVal lvItem As ListViewItem)

Private Sub RemoveListViewItem(ByVal lv As ListView, ByVal lvItem As ListViewItem)

    If lv.InvokeRequired Then
        lv.Invoke(New RemoveListViewItemDelegate(AddressOf AddListViewItem), New Object() {lv, lvItem})
    Else
        lv.Items.Remove(lvItem)
    End If

End Sub

Public Sub New()
    MyBase.New()

    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Monitor all the installed printers 
    pmon.MonitorJobAddedEvent = True
    pmon.MonitorJobDeletedEvent = True
    pmon.MonitorJobSetEvent = True
    pmon.MonitorJobWrittenEvent = True

    For Each p As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters

        pmon.AddPrinter(p)
        pmon.PrinterInformation(p).PauseAllNewJobs = True


    Next p




End Sub

Private Sub pmon_JobAdded(ByVal sender As Object, ByVal e As PrintJobEventArgs) Handles pmon.JobAdded
    Try
        Dim lvitem As ListViewItem = New ListViewItem

        With CType(e, PrintJobEventArgs)
            lvitem.SubItems.Clear()
            lvitem.Text = Nothing

            With .PrintJob
                lvitem.Text = .JobId
                lvitem.SubItems.Add(.MachineName)
                lvitem.SubItems.Add(.UserName)
                lvitem.SubItems.Add(.PrinterName)
                lvitem.SubItems.Add(.TotalPages)
                lvitem.SubItems.Add(.StatusDescription)
                lvitem.SubItems.Add(.Priority)

            End With

            AddListViewItem(ListView1, lvitem)


            ' ListView1.Items.Remove(lvitem)
            Trace.WriteLine("New job added " & .PrintJob.UserName)

        End With
    Catch ex As Exception
        MessageBox.Show(ex.Message)

    End Try
End Sub

So i need to select a job then send a action command, to the job in the printer. e.g like if Select Print the the job that job is printed.

Please help.
Nov 11, 2013 at 1:13 PM
Hi Mugove

Were you able to resume a particular print job again.

If so, could you perhaps share how you have done it..
Coordinator
Dec 2, 2013 at 12:28 PM
May 16, 2014 at 9:39 PM
print it with this command:
Shell("wmic printjob where jobid=56 resume")

I canceled this:
Shell("wmic printjob where jobid=56 delete")