public void flush() {synchronized (lock) {if (out != null) {try {out.flush();} catch (IOException e) {setError();}} else {setError();}}}
public override void flush(){lock (@lock){if (@out != null){try{@out.flush();}catch (System.IO.IOException){setError();}}else{setError();}}}