ISponsor 인터페이스

정의

구현자가 수명 임대 스폰서가 되려고 한다는 것을 나타냅니다.

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
파생
특성

예제

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

설명

개체를 구현 해야 합니다는 ISponsor 특정 개체에 대 한 임대 갱신을 요청 해야 하는 경우 인터페이스. 구현 하는 개체는 ISponsor 인터페이스 스폰서를 임대 관리자를 사용 하 여 자체 등록 될 수 있습니다. ISponsor 인터페이스는 스폰서를 콜백할 수명 서비스에서 사용 됩니다.

메서드

Renewal(ILease)

보증 클라이언트에게 지정된 개체의 임대를 갱신하도록 요청합니다.

적용 대상