ISponsor.Renewal Method (ILease)

 

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

Namespace:   System.Runtime.Remoting.Lifetime
Assembly:  mscorlib (in mscorlib.dll)

[SecurityCriticalAttribute]
TimeSpan Renewal(
	ILease lease
)

Parameters

lease
Type: System.Runtime.Remoting.Lifetime.ILease

The lifetime lease of the object that requires lease renewal.

Return Value

Type: System.TimeSpan

The additional lease time for the specified object.

Exception Condition
SecurityException

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

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

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

   [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)]
   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);
   }
}

SecurityPermission

for operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission value: SecurityPermissionFlag.Infrastructure

.NET Framework
Available since 1.1
Return to top
Show: