Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Close Remote Session
#8
(05-11-2021, 10:45 AM)Alexandre Machado Wrote: This code works correctly, as expected.
It terminates locks and terminates the session.

I believe that your problem is that you are trying to lock (and terminate) the same session that is running the command and that, by design, is not allowed. You can terminate all other sessions, except your own session, using this code.
To terminate your own session you must explicitly call IWApplication.Terminate, as usual.

Another point is that you don't need (nor should) release the application forms. The Session itself takes care of all forms when it is being released.

Code:

Code:
procedure TIWForm1.TerminateSession(const AAppId: string);
var
  lApp: TIWApplication;
  lExpired, lLocked: Boolean;
begin
  lApp := gSessions.LookupAndLock(AAppId, lExpired, lLocked);
  if Assigned(lApp) and not lExpired then
  begin
    try
      lApp.Terminate;
    finally
      lApp.Unlock;
    end;
  end;
end;

Hi!

I will try it and let you know the results. Thanks!
Reply


Messages In This Thread
Close Remote Session - by Rolphy Reyes - 05-04-2021, 09:41 PM
RE: Close Remote Session - by DanBarclay - 05-05-2021, 03:40 AM
RE: Close Remote Session - by Rolphy Reyes - 05-05-2021, 01:43 PM
RE: Close Remote Session - by Alexandre Machado - 05-05-2021, 11:23 PM
RE: Close Remote Session - by Jose Nilton Pace - 05-06-2021, 11:43 AM
RE: Close Remote Session - by Alexandre Machado - 05-11-2021, 10:45 AM
RE: Close Remote Session - by Alexandre Machado - 05-11-2021, 10:45 AM
RE: Close Remote Session - by Rolphy Reyes - 05-11-2021, 03:06 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)