ISponsor Interfaccia

Definizione

Indica che l'implementatore intende essere sponsor di lease di durata.

public interface class ISponsor
public interface ISponsor
[System.Runtime.InteropServices.ComVisible(true)]
public interface ISponsor
type ISponsor = interface
[<System.Runtime.InteropServices.ComVisible(true)>]
type ISponsor = interface
Public Interface ISponsor
Derivato
Attributi

Esempio

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

Commenti

Un oggetto deve implementare l'interfaccia ISponsor se deve richiedere un rinnovo del lease per un determinato oggetto. Un oggetto che implementa l'interfaccia ISponsor può diventare uno sponsor registrandosi con il gestore di lease. L'interfaccia ISponsor viene usata dal servizio di durata per richiamare lo sponsor.

Metodi

Renewal(ILease)

Chiede a un client sponsor di rinnovare il lease per l'oggetto specificato.

Si applica a