LinePrinter Tutorial > Part 2 of 6

Part 2: Expand Main to include error handling

        static void Main(string[] args)
        {
           try   {
                lp = new LinePrinter"ITC_CONFIG.XML", "PR2Bt_40COL");
                lp.Open();
                lp.Write("Hello World");
                lp.NewLine();
                lp.Close();
            }   catch (Exception x)
            {
                try {lp.Close();}
                catch{} // Ignore any errors coming from Close this time.
                ShowError(x);
            }
        }

Next » Tutorial Part 3

Back « Tutorial Part 1