//出力が終わったらSerialHandlerの設定用メソッドをたたく private void Process_Exit(object sender, EventArgs e) { sh.SetPortName(PortNum); Process proc = (Process)sender; proc.Kill(); }