void UpdateState() { //已離開則清空 if (Process != null && Process.HasExited) { Process = null; } //確認關聯 if (Process == null) { Process = ProcessUtility.GetProcess(ProcessName); } else { Process = System.Diagnostics.Process.GetProcessById(Process.Id); } bool isNull = Process == null; }