Fix: 상태머신 루프 블로킹 문제 수정 - SPS 이벤트 핸들러 비동기 처리 및 타임아웃 보호 추가
- sm_SPS 이벤트 핸들러에서 장치 연결 및 상태 전송을 비동기로 처리 - DeviceConnectionWorker 스레드로 장치 연결 분리 - SPS(1초), Running(2초) 타임아웃 보호 추가 - 상태머신 모니터링 디버그 창 추가 (fStateMachineDebug) - F11/F12 단축키로 스레드 덤프 및 디버그 브레이크 지원 - RaiseMessage 이벤트 비동기 처리로 로그 블로킹 방지
This commit is contained in:
@@ -20,7 +20,27 @@ namespace Project.StateMachine
|
||||
public event EventHandler<StateMachineMessageEventArgs> Message;
|
||||
void RaiseMessage(string header, string msg)
|
||||
{
|
||||
if (Message != null) Message(this, new StateMachineMessageEventArgs(header, msg));
|
||||
if (Message != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 비동기로 이벤트 발생 (블로킹 방지)
|
||||
var handler = Message;
|
||||
if (handler != null)
|
||||
{
|
||||
var args = new StateMachineMessageEventArgs(header, msg);
|
||||
System.Threading.ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
handler(this, args);
|
||||
}
|
||||
catch { /* 이벤트 핸들러 예외 무시 */ }
|
||||
});
|
||||
}
|
||||
}
|
||||
catch { /* 예외 무시 */ }
|
||||
}
|
||||
}
|
||||
|
||||
public class StepChangeEventArgs : EventArgs
|
||||
|
||||
Reference in New Issue
Block a user