TCriticalSection用法

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

ReadLocker.Leave;

if Assigned(ReadLocker) then
FreeAndNil(ReadLocker);

 

posted @ 2016-06-22 20:26  海蓝7  阅读(1216)  评论(0编辑  收藏  举报