After you have generated a report and sent it to the printer, you need to clean up resources.
Cleanup for the LinePrinter is easy. You must call the Close method and release any event handlers that were registered. See the example below.
This method releases resources used for printing.
public int Close()
Return:
Example:
Close();
This method cancels the remainder of print operations. This should also be called by applications if a recoverable error occurs but the user opts to cancel the remaining print operations. A status message is sent to the application to verify that printing was cancelled.
public void Cancel()
Return:
Example:
Cancel();
This property returns true if a print job is actively being sent to the printer or currently printing.
static public bool StillPrinting
//Read only property.
Example:
Bool isPrinting = lp.StillPrinting();
lp.Close();
.
.
.
LinePrinter.WarningMessageEventEx -= new
LinePrinter.WarningMessageEventHandler(WarningHandler);
LinePrinter.HeaderEventEx -= new
LinePrinter.HeaderEventHandler(PrintHeader);
LinePrinter.FooterEventEx -= new
LinePrinter.FooterEventHandler(PrintFooter);
LinePrinter.StatusMessageEventEx -= new
LinePrinter.StatusMessageEventHandler(DisplayStatus);
Next » Print Routine: Handle Errors
Back « Print Routine: Generate a Report