Share via


ClientSponsor.Renewal(ILease) Yöntem

Tanım

Bir sponsor istemciden belirtilen nesnenin kirasını yenilemesini istemektedir.

public:
 virtual 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
override this.Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
[<System.Security.SecurityCritical>]
abstract member Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
override this.Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
Public Function Renewal (lease As ILease) As TimeSpan

Parametreler

lease
ILease

Kira yenilemesi gerektiren nesnenin yaşam süresi kiralaması.

Döndürülenler

Belirtilen nesne için ek kiralama süresi.

Uygulamalar

Öznitelikler

Örnekler

int main()
{
   // Register a channel.
   TcpChannel^ myChannel = gcnew TcpChannel;
   ChannelServices::RegisterChannel( myChannel );
   RemotingConfiguration::RegisterActivatedClientType(
      RemotingSamples::HelloService::typeid, "tcp://localhost:8085/" );
   
   // Get the remote Object*.
   RemotingSamples::HelloService ^ myService = gcnew RemotingSamples::HelloService;
   
   // Get a sponsor for renewal of time.
   ClientSponsor^ mySponsor = gcnew ClientSponsor;
   
   // Register the service with sponsor.
   mySponsor->Register( myService );
   
   // Set renewaltime.
   mySponsor->RenewalTime = TimeSpan::FromMinutes( 2 );
   
   // Renew the lease.
   ILease^ myLease = dynamic_cast<ILease^>(mySponsor->InitializeLifetimeService());
   TimeSpan myTime = mySponsor->Renewal( myLease );
   Console::WriteLine( "Renewed time in minutes is {0}", myTime.Minutes );
   
   // Call the remote method.
   Console::WriteLine( myService->HelloMethod( "World" ) );
   
   // Unregister the channel.
   mySponsor->Unregister( myService );
   mySponsor->Close();
}
class HelloClient
{
    static void Main()
   {
      // Register a channel.
      TcpChannel myChannel = new TcpChannel ();
      ChannelServices.RegisterChannel(myChannel);
      RemotingConfiguration.RegisterActivatedClientType(
                             typeof(HelloService),"tcp://localhost:8085/");

      // Get the remote object.
      HelloService myService = new HelloService();

      // Get a sponsor for renewal of time.
      ClientSponsor mySponsor = new ClientSponsor();

      // Register the service with sponsor.
      mySponsor.Register(myService);

      // Set renewaltime.
      mySponsor.RenewalTime = TimeSpan.FromMinutes(2);

      // Renew the lease.
      ILease myLease = (ILease)mySponsor.InitializeLifetimeService();
      TimeSpan myTime = mySponsor.Renewal(myLease);
      Console.WriteLine("Renewed time in minutes is " + myTime.Minutes.ToString());

      // Call the remote method.
      Console.WriteLine(myService.HelloMethod("World"));

      // Unregister the channel.
      mySponsor.Unregister(myService);
      mySponsor.Close();
   }
}
Class HelloClient

   Shared Sub Main()
      ' Register a channel.
      Dim myChannel As New TcpChannel()
      ChannelServices.RegisterChannel(myChannel)
      RemotingConfiguration.RegisterActivatedClientType( _
                  GetType(HelloService), "tcp://localhost:8085")

      ' Get the remote object.
      Dim myService As New HelloService()

      ' Get a sponsor for renewal of time.
      Dim mySponsor As New ClientSponsor()

      ' Register the service with sponsor.
      mySponsor.Register(myService)

      ' Set renewaltime.
      mySponsor.RenewalTime = TimeSpan.FromMinutes(2)

      ' Renew the lease.
      Dim myLease As ILease = CType(mySponsor.InitializeLifetimeService(), ILease)
      Dim myTime As TimeSpan = mySponsor.Renewal(myLease)
      Console.WriteLine("Renewed time in minutes is " & myTime.Minutes)

      ' Call the remote method.
      Console.WriteLine(myService.HelloMethod("World"))

      ' Unregister the channel.
      mySponsor.Unregister(myService)
      mySponsor.Close()
   End Sub
End Class

Açıklamalar

yöntemi Renewal , belirtilen nesnenin kirasını yenilemek için dağıtılmış çöp toplayıcı tarafından çağrılır.

Şunlara uygulanır