TCriticalSection用法
ReadLocker : TCriticalSection; ReadLocker := TCriticalSection.Create; ReadLocker.Enter; //锁住你想保护的代码 //至于是否在线程中,有待考究,目前看有些代码不在线程中也这样用它,为何? ReadLocker.Leave; if Assigned(ReadLocker) then FreeAndNil(ReadLocker);
ReadLocker : TCriticalSection; ReadLocker := TCriticalSection.Create; ReadLocker.Enter; //锁住你想保护的代码 //至于是否在线程中,有待考究,目前看有些代码不在线程中也这样用它,为何? ReadLocker.Leave; if Assigned(ReadLocker) then FreeAndNil(ReadLocker);