

loop, that is bounded by the number of TryEnter calling efforts. I would like to have the method TryAcquire, but there is no such method, so - I am considering to replace all my calls to Acquire with TryEnter. Enter calls the Acquire method to bind the Call Enter to block all other threads fromĮntering code protected by this critical section until the Leave or Acquire does theĮnter: Blocks other threads when the calling thread enters a Section until the Release or Leave method is called. CallĪcquire to block all other threads from acquiring this critical

!!MEMBERTYPE_Methods_SyncObjs_TCriticalSection.htmlĪcquire: Binds the critical section to the calling thread. My question is - what is the difference between Acquire and Enter?ĭelphi documentation is quite obscure - it even tries to say, that there is no difference: ProgressBar.Position := ProgressBar.I am updating Delphi (Delphi 2009) code which uses exclusively TCriticalSection.Acquire/Release pairs, not Enter/Release or Leave pairs. Procedure TForm1.Timer1Timer(Sender: TObject) ShowMessage("done in " + FormatFloat("#", TimeElapsed) + " milliseconds") Procedure TForm1.ThreadTerminated(Sender: TObject) If Dir "" then Dir := IncludeTrailingPathDelimiter(Dir) If (Ret >= WAIT_OBJECT_0) and (Ret nil then If Ret := WAIT_FAILED then RaiseLastOSError

Ret := WaitForMultipleObjects(NumThreads, False, INFINITE) GetFileStringList(Dir + "*.db", FileList) While Done "" then Dir := IncludeTrailingPathDelimiter(Dir) GetFileStringList(TargetDir.Text + "*.db", FileList) Procedure TForm1.Button1Click(Sender: TObject) Leave the critical section, when there are no files leftĬopyTable(ChangeFileExt(filename,""),) While not FIleDone do //while there are still filesĮnterCriticalSection(CriticalSection) //Try to catch the critical section
