我已经注册了我的申请ARR。假设我的应用程序有一个IdTCPServer
,它使用VSPE
从串口读取数据,并将其添加到ClientDataSet
。如果主线程冻结,ARR将调用我的ApplicationRecoveryCallback()。我可以安全地访问恢复回调函数中的IdTCPServer
吗?我希望它停止,以便我可以在重新启动之前将我的ClientDataSet
保存到磁盘。我可以这样简单地写我的功能吗?如何防止ApplicationRecoveryCallback()中的死锁?
function RecoveryFunction(pvParameter: Pointer): DWORD; stdcall;
var
ContinueRecovery: Boolean;
begin
Result := 0; // happy compiler ;-)
repeat
ApplicationRecoveryInProgress(ContinueRecovery);
if not ContinueRecovery then
ApplicationRecoveryFinished(False);
until frmInstrument.CriticalSection.TryEnter;
frmInstrument.IdTCPServer.Active := False;
frmInstrument.CDS.SaveToFile(RecoveryFile);
ApplicationRecoveryFinished(True);
end;
为什么不停止应用程序冻结在第一位? –
@DavidHeffernan好问题,但这是最后一项节省宝贵数据的努力,如果我的应用程序将会死亡。我从串口收集的数据来自一堆没有内存的医疗实验室仪器,所以当我收到一个包时,我应该用我的生活来保护它,可以这么说。 –
你可以立即将它写入磁盘来保护它。当你这样做时,不需要恢复,因为你已经保存了所有可用的东西。 ARR文件就是这样建议的。 –