Clean Up Resources

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.

Close Method

This method releases resources used for printing.

public int Close()

Return:

Example:

Close();

Cancel Method

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();

StillPrinting Property

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();

Example

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);

More Information

Next » Print Routine: Handle Errors

Back « Print Routine: Generate a Report