I need to catch an event when the user launches a print job on a specific printqueue and I don't find any event in System.printing namespace that looks useful to it. I already had a look on these topics :
I also tried this piece of code :
public static void WritePrinterJobs()
{
while (true)
{
foreach (var job in LocalPrintServer.GetDefaultPrintQueue().GetPrintJobInfoCollection())
{
Console.WriteLine(job.Submitter + " " + job.TimeJobSubmitted.ToShortDateString());
}
Thread.Sleep(100);
}
}
Even if this code work, don't think a while(true) loop is very memory-friendly, especially in my case, because i need to constantly listen to print jobs event.
I also checked the FindFirstPrinterChangeNotification : https://learn.microsoft.com/fr-fr/windows/win32/printdocs/findfirstprinterchangenotification?redirectedfrom=MSDN
But it seems to be a C++ function and I haven't figured out how to make it work in C#.
If someone would help me it would be awesome!
If you need any precisions, just ask !