ISponsor.Renewal(ILease) Metoda

Definice

Požádá sponzorujícího klienta o prodloužení zapůjčení pro zadaný objekt.

public:
 TimeSpan Renewal(System::Runtime::Remoting::Lifetime::ILease ^ lease);
public TimeSpan Renewal (System.Runtime.Remoting.Lifetime.ILease lease);
[System.Security.SecurityCritical]
public TimeSpan Renewal (System.Runtime.Remoting.Lifetime.ILease lease);
abstract member Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
[<System.Security.SecurityCritical>]
abstract member Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
Public Function Renewal (lease As ILease) As TimeSpan

Parametry

lease
ILease

Životnost zapůjčení objektu, který vyžaduje prodloužení zapůjčení.

Návraty

TimeSpan

Další doba zapůjčení pro zadaný objekt.

Atributy

Výjimky

Okamžitý volající provede volání prostřednictvím odkazu na rozhraní a nemá oprávnění k infrastruktuře.

Příklady

public ref class MyClientSponsor: public MarshalByRefObject, public ISponsor
{
private:
   DateTime lastRenewal;

public:
   MyClientSponsor()
   {
      lastRenewal = DateTime::Now;
   }

   [SecurityPermissionAttribute(SecurityAction::LinkDemand,Flags=SecurityPermissionFlag::Infrastructure)]
   virtual TimeSpan Renewal( ILease^ /* lease */ )
   {
      Console::WriteLine( "Request to renew the lease time." );
      Console::WriteLine( "Time since last renewal: {0}",
         DateTime::Now - lastRenewal );

      lastRenewal = DateTime::Now;
      return TimeSpan::FromSeconds( 20 );
   }
};
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);
   }
}
Public Class MyClientSponsor
   Inherits MarshalByRefObject
   Implements ISponsor 
   Private lastRenewal As DateTime
   
   Public Sub New()
      lastRenewal = DateTime.Now
   End Sub
   
   <SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
   Public Function Renewal(lease As ILease) As TimeSpan Implements ISponsor.Renewal
      Console.WriteLine("Request to renew the lease time.")
      Console.WriteLine("Time since last renewal: " + _ 
                      DateTime.op_Subtraction(DateTime.Now, lastRenewal).ToString())
      
      lastRenewal = DateTime.Now
      Return TimeSpan.FromSeconds(20)
   End Function 'Renewal
End Class

Poznámky

Metoda Renewal je volána distribuovaným uvolňováním paměti pro obnovení zapůjčení pro zadaný objekt.

Platí pro