private static void StopMarkAndReset(ILaser laser, IRtc rtc) { Console.WriteLine("Trying to abort ..."); //abort to mark rtc.CtlAbort(); //wait for rtc busy off rtc.CtlBusyWait(); //wait for thread has finished Program.thread?.Join(); Program.thread = null; //reset rtc's status rtc.CtlReset(); }