Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with getting session list
#3
I don't understand what you are trying to accomplish exactly... You said that you are trying to terminate some forms but you are actually terminating some sessions, correct?

How's this method called/triggered? From an user event?

You are terminating one specific session from another session (i.e. from Session A you terminate Session B)?

If so, the code looks good to me, most of it. But the problem relies on the terminate itself. *Don't free the session yourself*.

Code:
    if aid <> ASession.AppID then begin
      app:= gSessions.LookupAndLock(aid, exp, al);
      if Assigned(app) and not exp then begin
        if app.Name = ASession.Name then begin
          if _LogEnabled then
            _Log('Session "' + app.AppID + '" will be terminated');
          app.Terminate;  // terminate first
        end;
        app.Unlock;      // then unlock it. Don't free it!
      end;
    end;

After being terminated, session will be collected by the clean up thread which runs in the background, and freed. If you free it yourself, the clean up thread won't be able to do the proper clean up.
Reply


Messages In This Thread
RE: Problem with getting session list - by Alexandre Machado - 09-09-2020, 10:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)