public static void Close() { if(_gates!=null) { lock(_gates) { var gates=_gates.Select(z => z as MsGSerial).Where(z => z!=null).ToArray(); for(int i=0; i<gates.Length; i++) { gates[i].Stop(); } } } }