Failing to Renew the Lease

As previously said, if you fail to renew a lease, the remote object is removed from the remoting infrastructure and released for garbage collection.

Although this doesn’t ensure that the object will be freed immediately, it guarantees that any subsequent call to it will fail.

To illustrate this, you can modify the unit SimpleServer_Impl.pas, by commenting out the line where it renews the lease. It will look as shown below:

function TSimpleServer.Renewal(Lease: ILease): TimeSpan;
begin
  writeln('Request for renewal for TSimpleServer');
  // Comment the following line to prevent lease renewal
  // Lease.Renew(TimeSpan.FromMinutes(LeaseDurationInMinutes));
end;
  • Find the code on the CD: \Chapter 30\Ex03.

By doing this, the lease ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.