>If MyDataDictionary Is Nothing Then > SyncLock LockDictionaryObject > If MyDataDictionary Is Nothing Then > If Not LoadDataDictionary() Then > Return False > End If > ' Do other stuff > End If > End SyncLock >End If >The problem with this approach is that this would be ok if I would only have LoadDataDictionary() to be called in the lock. But, after that, I do more process and I need to keep the lock. So, right now I have this:
If oApp.lFirstHit Then oApp.lFirstHit = False SyncLock oApp.oObjectLock If Not oApp.lInitialize Then If Not LoadDataDictionary() Then Return False End IfThe only improvement I could see here would be to add a verification as you mentioned such as this:
If oApp.lFirstHit Then oApp.lFirstHit = False If Not oApp.lInitialize Then SyncLock oApp.oObjectLock If Not oApp.lInitialize Then If Not LoadDataDictionary() Then Return False End IfSo, basically, it would avoid using SyncLock if the application has been initialized.