V1.0.1.8 -- 2025/12/20
* BMS History Function Improved
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO.Ports;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using LFP_Manager.DataStructure;
|
||||
using LFP_Manager.Function;
|
||||
using LFP_Manager.Utils;
|
||||
@@ -460,10 +461,11 @@ namespace LFP_Manager.Threads
|
||||
break;
|
||||
|
||||
case 2: // Firmware update packet
|
||||
if (OnPrint != null)
|
||||
{
|
||||
OnPrint(this, csLog.trx_data_print(_readBuffer, _readPosition, 1));
|
||||
}
|
||||
SafeRaiseOnPrint(csLog.trx_data_print(_readBuffer, _readPosition, 1));
|
||||
//if (OnPrint != null)
|
||||
//{
|
||||
// OnPrint(this, csLog.trx_data_print(_readBuffer, _readPosition, 1));
|
||||
//}
|
||||
_timeoutCount = 0;
|
||||
ProcessFirmwareResponse();
|
||||
break;
|
||||
@@ -702,5 +704,22 @@ namespace LFP_Manager.Threads
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SAFE CALLS
|
||||
private void SafeRaiseOnPrint(string msg)
|
||||
{
|
||||
var handler = OnPrint; // 복사
|
||||
if (handler == null) return;
|
||||
|
||||
// 비차단 + 예외격리: 핸들러를 ThreadPool에서 실행
|
||||
Task.Run(() =>
|
||||
{
|
||||
try { handler.Invoke(this, msg); }
|
||||
catch (Exception ex) { /* 내부 로깅 */ }
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user