ClientSponsor ClientSponsor ClientSponsor ClientSponsor Class

정의

수명 스폰서 클래스에 대한 기본 구현을 제공합니다.Provides a default implementation for a lifetime sponsor class.

public ref class ClientSponsor : MarshalByRefObject, System::Runtime::Remoting::Lifetime::ISponsor
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public class ClientSponsor : MarshalByRefObject, System.Runtime.Remoting.Lifetime.ISponsor
type ClientSponsor = class
    inherit MarshalByRefObject
    interface ISponsor
Public Class ClientSponsor
Inherits MarshalByRefObject
Implements ISponsor
상속
특성
구현

예제

다음 예제에서는 클래스 활성 원격 개체의 수명을 연장 하 ClientSponsor 클래스를 보여 줍니다.The following example illustrates the ClientSponsor class to extend the life of a class-activated remote object.

#using <system.dll>
#using <system.runtime.remoting.dll>
#using <ClientSponsor_Share.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
using namespace System::Runtime::Remoting::Lifetime;

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();
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Lifetime;
namespace RemotingSamples
{

   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();
      }
   }

}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Lifetime

Namespace RemotingSamples

   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 'HelloClient


End Namespace 'RemotingSamples

설명

현재 수명 스폰서 구현이 필요한 갱신을 지정 하 여 개체를 사용할 수 TimeSpan입니다.The current lifetime sponsor implementation can be used to sponsor objects by specifying the required renewal TimeSpan.

참고

이 클래스는 클래스 수준에서 상속 요청과 링크 요청을 만듭니다.This class makes a link demand and an inheritance demand at the class level. SecurityException 직접 실행 호출자 또는 파생된 클래스 중 하나에 인프라 권한이 없는 경우 throw 됩니다.A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. 보안 요청에 대 한 자세한 내용은 참조 하세요 링크 요청 하 고 상속 요청합니다.For details about security demands, see Link Demands and Inheritance Demands.

생성자

ClientSponsor() ClientSponsor() ClientSponsor() ClientSponsor()

기본값을 사용하여 ClientSponsor 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ClientSponsor class with default values.

ClientSponsor(TimeSpan) ClientSponsor(TimeSpan) ClientSponsor(TimeSpan) ClientSponsor(TimeSpan)

보증된 개체의 갱신 시간을 사용하여 ClientSponsor 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ClientSponsor class with the renewal time of the sponsored object.

속성

RenewalTime RenewalTime RenewalTime RenewalTime

갱신이 요청된 경우 보증된 개체의 수명이 증가할 TimeSpan을 가져오거나 설정합니다.Gets or sets the TimeSpan by which to increase the lifetime of the sponsored objects when renewal is requested.

메서드

Close() Close() Close() Close()

현재 ClientSponsor를 사용하여 등록된 목록 개체를 비웁니다.Empties the list objects registered with the current ClientSponsor.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

가비지 수집기가 회수하기 전에 현재 ClientSponsor의 리소스를 해제합니다.Frees the resources of the current ClientSponsor before the garbage collector reclaims them.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

현재 개체에 대한 임대를 제공하여 ClientSponsor의 새 인스턴스를 초기화합니다.Initializes a new instance of ClientSponsor, providing a lease for the current object.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Register(MarshalByRefObject) Register(MarshalByRefObject) Register(MarshalByRefObject) Register(MarshalByRefObject)

보증에 대해 지정된 MarshalByRefObject를 등록합니다.Registers the specified MarshalByRefObject for sponsorship.

Renewal(ILease) Renewal(ILease) Renewal(ILease) Renewal(ILease)

보증 클라이언트에게 지정된 개체의 임대를 갱신하도록 요청합니다.Requests a sponsoring client to renew the lease for the specified object.

ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)
Unregister(MarshalByRefObject) Unregister(MarshalByRefObject) Unregister(MarshalByRefObject) Unregister(MarshalByRefObject)

현재 MarshalByRefObject를 통해 보증된 개체 목록에서 지정된 ClientSponsor 등록을 취소합니다.Unregisters the specified MarshalByRefObject from the list of objects sponsored by the current ClientSponsor.

보안

SecurityPermission
한 인프라 코드를 사용 하 여 작동 합니다.for operating with infrastructure code. 요청 값: InheritanceDemand; 권한 값: InfrastructureDemand value: InheritanceDemand; Permission Value: Infrastructure

적용 대상