I'm using TIDTCPServer component. As I understood event ServerTCPExecute(AContext: TIdContext)
is not synchronized. What is the best way of synchronising it? I need data to be send to main thread and have them back to format answer.
I'm using Indy 10.5.8.0.
Method 1
Is it something like this I should deal with critical sections to pass data from non synchronized function to application?
var data:string;
.
.
.
procedure MainThreadProcedure;
begin
...
end;
.
.
.
procedure IdTCPServerExecute(AContext: TIDContext);
var tmp: string;
begin
.
.
.
EnterCriticalSection(cs);
data:= tmp;
TIdYarnOfThread(AContext.Yarn).Thread.Synchronize(MainThreadProcedure);
LeaveCriticalSection(cs);
end;
See Question&Answers more detail:os