/// <summary> /// Start watching print events /// </summary> public void Start() { lock (accesslock) { if (!isRunning) { Task.Factory.StartNew(() => { isRunning = true; printers = new ArrayList(); printServer = new PrintServer(); foreach (var pq in printServer.GetPrintQueues()) { var pqm = new PrintQueueHook(pq.Name); pqm.OnJobStatusChange += pqm_OnJobStatusChange; pqm.Start(); printers.Add(pqm); } }, CancellationToken.None, TaskCreationOptions.None, factory.GetTaskScheduler()).Wait(); } } }
/// <summary> /// Start watching print events /// </summary> public static void Start(string printerName) { //if (!isRunning) { lock (accesslock) { printers = new ArrayList(); printServer = new PrintServer(); PrintQueue printQueue = printServer.GetPrintQueue(printerName); var pqHook = new PrintQueueHook(printQueue.Name); pqHook.OnJobStatusChange += pqm_OnJobStatusChange; pqHook.Start(); printers.Add(pqHook); isRunning = true; } } }
/// <summary> /// Start watching print events /// </summary> public static void Start() { if (!isRunning) { lock (accesslock) { printers = new ArrayList(); printServer = new PrintServer(); foreach (var pq in printServer.GetPrintQueues()) { var pqm = new PrintQueueHook(pq.Name); pqm.OnJobStatusChange += pqm_OnJobStatusChange; pqm.Start(); printers.Add(pqm); } isRunning = true; } } }