ISponsor.Renewal(ILease) Method

Definition

Requests a sponsoring client to renew the lease for the specified object.

C#
public TimeSpan Renewal(System.Runtime.Remoting.Lifetime.ILease lease);
C#
[System.Security.SecurityCritical]
public TimeSpan Renewal(System.Runtime.Remoting.Lifetime.ILease lease);

Parameters

lease
ILease

The lifetime lease of the object that requires lease renewal.

Returns

The additional lease time for the specified object.

Attributes

Exceptions

The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.

Examples

C#
public class MyClientSponsor : MarshalByRefObject, ISponsor
{
   private DateTime lastRenewal;
   public MyClientSponsor()
   {
      lastRenewal = DateTime.Now;
   }

   public TimeSpan Renewal(ILease lease)
   {
      Console.WriteLine("Request to renew the lease time.");
      Console.WriteLine("Time since last renewal: " +
         (DateTime.Now - lastRenewal).ToString());

      lastRenewal = DateTime.Now;
      return TimeSpan.FromSeconds(20);
   }
}

Remarks

The Renewal method is called by the distributed garbage collector to renew the lease for the specified object.

Applies to

Produto Versións
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1