//スレッドを開始する /* * ・IsBackground=trueは必須。 * メインスレッド終了に伴ってこちらのスレッドも終了するようにする。 * Abort()でスレッドを終了できるようにする。 * ・理由: * ReadFile()でスレッドがブロック中のとき、メインスレッドが終了してもこのスレッドは残り、 * アプリが終了できないので。その状態のときはAbort()も効果がない。 */ public bool Start(InterruptInCB callbackMethod) { if (thObj != null) { return(false); //二重実行禁止 } if (callbackMethod == null) { return(false); } thParam.userMethod = callbackMethod; thObj = new Thread(ReadThread); thObj.IsBackground = true; thObj.Start(thParam); Thread.Sleep(1); //Start()した瞬間にIsAliveを見ても正しい状態が得られないので間(ま)を置く return(thObj.IsAlive); }
//インタラプト転送(IN)の受信スレッドを開始する public bool InterruptInStart(InterruptInCB callbackMethod) { return(intrInCtrl.Start(callbackMethod)); }