我已经注册了我的ARR申请。假设我的应用程序有一个IdTCPServer
使用从串行端口读取数据VSPE
并将其添加到ClientDataSet
. 如果主线程冻结,ARR 将调用我的 ApplicationRecoveryCallback()。我可以IdTCPServer
安全地访问恢复回调函数吗?我希望它停止,以便ClientDataSet
在重新启动之前将其保存到磁盘。我可以这样简单地编写我的函数吗?
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;