I am sending print jobs to the printer and I try to keep track of their status in order to reflect it in a queue of my own.
It seems as if the print jobs never go through "Printed", "Completed" status.
I made a small test program to see if maybe I was using the .net object the wrong way but this still happened. I ran my test program to query for a new print job and once there was a one I heavily polled it and refreshed every time to see its status and make sure I don't miss anything.
PrintServer ps = new PrintServer(@"\\printServer");
PrintQueue pq = new PrintQueue(ps, "PDF Writer - bioPDF");
PrintSystemJobInfo jobInfo = null;
while (jobInfo == null)
{
pq.Refresh();
var printJobs = pq.GetPrintJobInfoCollection();
foreach (var printJob in printJobs)
{
printJob.Refresh();
jobInfo = printJob;
break;
}
Thread.Sleep(100);
}
PrintJobStatus jobStatus = PrintJobStatus.None;
PrintJobStatus prevJobStatus = PrintJobStatus.None;
while (true)
{
try
{
jobInfo.Refresh();
} catch { }
prevJobStatus = jobStatus;
jobStatus = jobInfo.JobStatus;
if (jobStatus != prevJobStatus)
{
Console.WriteLine("**UPDATE**");
SpotTroubleUsingProperties(jobInfo); // Microsoft example method that prints a description of each possible job status
}
Thread.Sleep(20);
}
The result I get, even though the document is printed, is:
**UPDATE**
The job is spooling now.
**UPDATE**
The job is printing now.
**UPDATE**
The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.
How can I know when the document is in "Completed" status?