LifetimeServices LifetimeServices LifetimeServices LifetimeServices Class

정의

.NET Remoting 수명 서비스를 제어합니다.Controls the.NET remoting lifetime services.

public ref class LifetimeServices sealed
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public sealed class LifetimeServices
type LifetimeServices = class
Public NotInheritable Class LifetimeServices
상속
LifetimeServicesLifetimeServicesLifetimeServicesLifetimeServices
특성

예제

#using <system.dll>
#using <system.runtime.remoting.dll>
#using "service.dll"

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

int main()
{
   LifetimeServices::LeaseTime = TimeSpan::FromSeconds( 5 );
   LifetimeServices::LeaseManagerPollTime = TimeSpan::FromSeconds( 3 );
   LifetimeServices::RenewOnCallTime = TimeSpan::FromSeconds( 2 );
   LifetimeServices::SponsorshipTimeout = TimeSpan::FromSeconds( 1 );
   ChannelServices::RegisterChannel( gcnew HttpChannel( 8080 ) );
   RemotingConfiguration::RegisterActivatedServiceType( ClientActivatedType::typeid );
   Console::WriteLine( "The server is listening. Press Enter to exit...." );
   Console::ReadLine();
   Console::WriteLine( "GC'ing." );
   GC::Collect();
   GC::WaitForPendingFinalizers();
   return 0;
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Lifetime;
using System.Security.Permissions;

public class Server {

   public static void Main() {

      Server myServer = new Server();
      myServer.Run();
   }
 
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)]
   public void Run()
   {
      LifetimeServices.LeaseTime = TimeSpan.FromSeconds(5);
      LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(3);
      LifetimeServices.RenewOnCallTime = TimeSpan.FromSeconds(2);
      LifetimeServices.SponsorshipTimeout = TimeSpan.FromSeconds(1);
   
      ChannelServices.RegisterChannel(new HttpChannel(8080), true);
      RemotingConfiguration.RegisterActivatedServiceType(typeof(ClientActivatedType));
      
      Console.WriteLine("The server is listening. Press Enter to exit....");
      Console.ReadLine();  

      Console.WriteLine("GC'ing.");
      GC.Collect();
      GC.WaitForPendingFinalizers();
   }
}
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http
Imports System.Runtime.Remoting.Lifetime
Imports System.Security.Permissions


Public Class Server
   
   Public Shared Sub Main()
      Dim myServer As New Server()
      myServer.Run()
   End Sub 'Main

<SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.Infrastructure)> _ 
   Public Sub Run()
      LifetimeServices.LeaseTime = TimeSpan.FromSeconds(5)
      LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(3)
      LifetimeServices.RenewOnCallTime = TimeSpan.FromSeconds(2)
      LifetimeServices.SponsorshipTimeout = TimeSpan.FromSeconds(1)
      
      
      ChannelServices.RegisterChannel(New HttpChannel(8080), True)
      RemotingConfiguration.RegisterActivatedServiceType(GetType(ClientActivatedType))
      
      Console.WriteLine("The server is listening. Press Enter to exit....")
      Console.ReadLine()
      
      Console.WriteLine("GC'ing.")
      GC.Collect()
      GC.WaitForPendingFinalizers()
   End Sub 'Run
   
End Class 'Server

설명

분산된 된 가비지 수집은 수명이 만료 된 경우 삭제 한 서버 애플리케이션의 수명을 제어 합니다.Distributed garbage collection is responsible for controlling the lifetimes of server applications, and for deleting them when their lifetimes have expired. 일반적으로 분산된 된 가비지 수집 참조 횟수와 컨트롤에 대 한 ping을 사용 합니다.Traditionally, distributed garbage collection uses reference counts and pinging for control. 클라이언트 개체 수가 적은 경우에 잘 작동 하지만 수천 개의 개체 각 클라이언트가 사용 하는 경우 작동 하지 않습니다.This works well when there are a few clients per object, but does not work well when there are thousands of clients per each object. 클라이언트 수가 증가 하는 경우에 수명 서비스는 일반 가비지 수집기 및 확장의 기능을 가정할 수 있습니다.The lifetime service can assume the function of a traditional distributed garbage collector, and scales well when the number of clients increases.

수명 서비스는 각 원격으로 정품 인증된 개체를 사용 하 여 임대를 연결합니다.The lifetime service associates a lease with each remotely activated object. 임대가 만료 되 면 개체가 제거 됩니다.When the lease expires, the object is removed.

참고

이 클래스에는 링크 요청을 만듭니다.This class makes a link demand. SecurityException 직접 실행 호출자에 인프라 권한이 없는 경우 throw 됩니다.A SecurityException is thrown if the immediate caller does not have infrastructure permission. 참조 링크 요구가 자세한 내용은 합니다.See Link Demands for more information.

생성자

LifetimeServices() LifetimeServices() LifetimeServices() LifetimeServices()

LifetimeServices의 인스턴스를 만듭니다.Creates an instance of LifetimeServices.

속성

LeaseManagerPollTime LeaseManagerPollTime LeaseManagerPollTime LeaseManagerPollTime

만료된 임대를 정리하기 위해 임대 관리자가 활성화되는 시간 간격을 가져오거나 설정합니다.Gets or sets the time interval between each activation of the lease manager to clean up expired leases.

LeaseTime LeaseTime LeaseTime LeaseTime

AppDomain에 대한 초기 임대 시간 범위를 가져오거나 설정합니다.Gets or sets the initial lease time span for an AppDomain.

RenewOnCallTime RenewOnCallTime RenewOnCallTime RenewOnCallTime

서버 개체에 호출이 들어올 때마다 임대가 확장되는 시간을 가져오거나 설정합니다.Gets or sets the amount of time by which the lease is extended every time a call comes in on the server object.

SponsorshipTimeout SponsorshipTimeout SponsorshipTimeout SponsorshipTimeout

임대 갱신 시간과 함께 스폰서가 반환될 때까지 임대 관리자가 대기할 시간을 가져오거나 설정합니다.Gets or sets the amount of time the lease manager waits for a sponsor to return with a lease renewal time.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

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

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

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

보안

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

적용 대상