Hi!
I read that the TOmniCS is basically a wrapper around TCriticalSection, I'm using it with pipelines, the code is:
// ---------------------------------------------------------------- //
procedure my_routine();
var
AFile : TOmniValue;
begin
if Pipeline = nil then
Pipeline := Parallel.Pipeline.NumTasks(10).Stage(StageProc).Run;
AFile.CreateNamed(['FileURL', FileURL, 'FolderGUID', FolderGUID]);
Pipeline.Input.Add(AFile);
end;
// ---------------------------------------------------------------- //
procedure StageProc(const Input, Output : IOmniBlockingCollection; const Task : IOmniTask);
begin
Lock.Acquire; // <-- [ Lock ] is a TOmniCS that's declared & used globally all across my app.
try
// Do some critical DB stuff
finally
Lock.Release;
end; // try/finally
end;
// ---------------------------------------------------------------- //
But clearly Lock doesn't happen and I'm getting exceptions because of that.
My question is: how can I change this code to make locking happen?
Thanks in advance!
Khaled.