MESCIUS.ActiveReports.Viewer.Common Assembly / GrapeCity.ActiveReports Namespace / PrinterSettings Class / PrintingThreadErrorEvent Event
Example

PrintingThreadErrorEvent Event (PrinterSettings)
Occurs when an unhandled exception is thrown in the printing thread.
Syntax
'Declaration
 
Public Event PrintingThreadErrorEvent As PrintingThreadErrorEventHandler
 
Event Data

The event handler receives an argument of type PrintingThreadErrorEventArgs containing data related to this event. The following PrintingThreadErrorEventArgs properties provide information specific to this event.

PropertyDescription
Gets the printing thread exception.  
Remarks
This event is raised if an exception occurs within the thread dedicated to handling the printing process. Handling this event provides an opportunity to respond to errors that occur during printing, such as logging the error, notifying the user, or attempting to recover from the error condition. It is important to handle this event to maintain application stability, especially when using a separate thread for printing operations, as unhandled exceptions in threads can lead to application crashes.
Example
This example demonstrates how to subscribe to the PrintingThreadErrorEvent and handle it:
GrapeCity.ActiveReports.PrinterSettings printerSettings = new GrapeCity.ActiveReports.PrinterSettings();
printerSettings.PrintingThreadErrorEvent += PrinterSettings_PrintingThreadErrorEvent;
            
private void PrinterSettings_PrintingThreadErrorEvent(object sender, GrapeCity.ActiveReports.Printing.PrintingThreadErrorEventArgs e)
{
    Console.WriteLine($"An error occurred in the printing thread: {e.Exception.Message}");
    // Additional logic to handle the error can be added here, such as logging or user notification
}
See Also