TAdvLockApp Abort() Revisited

Hi Bruno!

I'm using the new Unlock method as in:

procedure AdvLockApp1Lock(Sender: TObject);     // OnLock
  if (UserName = '') then     // No user logged in, no need to lock application
      LogToFileG('I', 'Lock Application Aborted!', '', 'Application.log');  
      AdvLockApp1.UserName := UserName;
      AdvLockApp1.Password := UserPassword;

and the application crashes and is closed by windows.
LogToFileG executes 32,259 times!
Where is the best place to call UnLock method or what is the correct way to use it?
Also, if a user is logged the else part doesn't change the default user name and user password. The values in the object inspector remain.

Best Regards
Francisco Alvarado

It is expected that UnLock is called after Lock is completely finished, but here you do this during the Lock process itself in which the OnLock event is called.

If you do not want to perform a lock when UserName = '', I'd suggest to first check UserName before calling Lock instead of doing an UnLock during the Lock process.