static void Main(string[] args) { try { lp = new LinePrinter”ITC_CONFIG.XML", "PR2Bt_40COL"); lp.WarningMessageEventEx += new LinePrinter.WarningMessageEventHandler(WarningHandler); lp.Open(); for (int i = 1; i <= 100; i++) { lp.WriteLn("This is line " + i.ToString()); } lp.Close(); } catch (Exception x) { try {lp.Close();} catch{} // Ignore any errors coming from Close this time. ShowError(x); } lp.WarningMessageEventEx -= new LinePrinter.WarningMessageEventHandler(WarningHandler); }
These additions register a warning handler function with the LinePrinter class and deregister the warning handler after the report. They also change the lines for writing "Hello World" and the NewLine method with a loop for printing 100 lines of text, which gives time to produce errors and warnings.
Next » Tutorial Part 6
Back « Tutorial Part 4