这个问题经常被问到,我已经花了数小时阅读,尝试和测试,但没有结果。
我想这与我的2005年旧版本有关。
下面是我在Embarcadero论坛上阅读了Remy Lebeau回答的帖子后尝试的代码:
Thread: How to handle multiple HTTP sessions with Indy10 TIdHTTPServer
procedure TMainForm.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
Msg : String;
begin
if ARequestInfo.QueryParams <> '' then
begin
Msg := DateTimeToStr(Now) + ': ReqParam "' + ARequestInfo.QueryParams + '"';
TThread.Queue(nil,
procedure
begin
Memo1.Lines.Add(Msg);
end
);
AResponseInfo.ContentText := '<HTML><BODY>Query Params found.</BODY></HTML>';
end
else
begin
AResponseInfo.ContentText := '<HTML><BODY>Error: No Query Params.</BODY></HTML>';
Msg := DateTimeToStr(Now) + ': Error: No Query Params';
TThread.Queue(nil,
procedure
begin
Memo1.Lines.Add(Msg);
end
);
end;
end;
我的目标是以线程安全的方式访问备忘录或日志文件条目。 无法使用TThread.Synchronize()
或TThread.Queue()
进行编译。
按照雷米的建议添加TThread.Queue()
行时,出现的错误是:
E2029需要表达但找到过程
有人可以在Delphi 2005中使用替代方法吗?
编辑:这是我从代码完成中看到的内容: