private bool PrinterReadyToStart(string driverName, int timeoutInSeconds) { GraphicCode graphics; try { graphics = new GraphicCode(); return graphics.IsPrinterBusy(driverName, timeoutInSeconds); //returns true or false } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { graphics = null; } return false; }
private bool PrinterReadyToStart(string driverName, int timeoutInSeconds) { //boolean method to test whether the printer is ready to start using driverName and timeoutInSeconds parameters GraphicCode graphics;//creates graphics variable from the GraphicsCode.cs class try { graphics = new GraphicCode(); //creates new GraphicCode object and stores in graphics return graphics.IsPrinterBusy(driverName, timeoutInSeconds); //returns true or false } catch (Exception e) { //exception handler MessageBox.Show(e.ToString());//catches and displays resulting errors to prevent program crash } finally { //finally block runs whether there is an exception or not graphics = null; //sets graphics object to null after it has finished being used } return false; }