Partager via


How to: Renew a Lease

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

This code obtains a lease and extends it directly as shown in the following code example.

Example

Dim obj As New RemoteType()
Dim lease As ILease = CType(RemotingServices.GetLifetimeService(obj), ILease)
Dim expireTime As TimeSpan = lease.Renew(TimeSpan.FromSeconds(20))
RemoteType obj = new RemoteType();
ILease lease = (ILease)RemotingServices.GetLifetimeService(obj);
TimeSpan expireTime = lease.Renew(TimeSpan.FromSeconds(20));

Compiling the Code

This example requires:

  • References to the System.Runtime.Remoting.Lifetime namespace.

See Also

Concepts

Renewing Leases