title: Detect when a PrintDocument successfully prints (not just previewed)
body: <p>I'm doing some custom printing using a <a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx" rel="noreferrer">PrintDocument</a> in my application. I have a requirement of logging when our items are successfully printed. I originally achieved this with something like:</p>
  
  <pre><code> print_doc.EndPrint += (o,e) =&gt; printed_callback ();
  </code></pre>
  
  <p>To make my <code>printed_callback</code> get invoked when a print finished. However, now that I'm adding preview support, I'm passing a <code>PrintDocument</code> constructed in exactly the same way into a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.printpreviewdialog.aspx" rel="noreferrer">PrintPreviewDialog</a>. Doing so causes the <code>EndPrint</code> event to be invoked after the initial rendering of the printout needed for the preview.</p>
  
  <p>As a result, even if a user clicks "Preview" and then just closes the preview, our logging code gets invoked.</p>
  
  <p>Any suggestions for how to differentiate between a real printout and a "preview print" ? Unfortunately, I can't just not hook up to <code>EndPrint</code> for the <code>PrintDocument</code> passed to the <code>PrintPreviewDialog</code> since the user may click the "Print" button in the preview dialog and trigger a printout.</p>