LifetimeServices 클래스

정의

원격 .NET 수명 서비스를 제어합니다.

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

예제

#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;

public class Server {

   public static void Main() {

      Server myServer = new Server();
      myServer.Run();
   }

   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.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

<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
   
End Class

설명

분산 가비지 수집은 서버 애플리케이션의 수명을 제어하고 수명이 만료되었을 때 삭제해야 합니다. 일반적으로 분산 가비지 수집은 참조 개수 및 ping을 제어에 사용합니다. 이는 개체당 클라이언트가 몇 개 있을 때 잘 작동하지만 각 개체당 수천 개의 클라이언트가 있는 경우 제대로 작동하지 않습니다. 수명 서비스는 기존 분산 가비지 수집기의 기능을 가정할 수 있으며 클라이언트 수가 증가할 때 잘 확장됩니다.

수명 서비스는 임대를 원격으로 활성화된 각 개체와 연결합니다. 임대가 만료되면 개체가 제거됩니다.

메모

이 클래스는 링크 요청을 만듭니다. 즉시 호출자에게 인프라 권한이 없는 경우 SecurityException이 throw됩니다.

생성자

Name Description
LifetimeServices()
사용되지 않음.

LifetimeServices인스턴스를 만듭니다.

속성

Name Description
LeaseManagerPollTime

만료된 임대를 정리하기 위해 임대 관리자의 각 활성화 사이의 시간 간격을 가져오거나 설정합니다.

LeaseTime

에 대한 AppDomain초기 임대 시간 범위를 가져오거나 설정합니다.

RenewOnCallTime

서버 개체에서 호출이 들어올 때마다 임대가 연장되는 시간을 가져오거나 설정합니다.

SponsorshipTimeout

임대 관리자가 임대 갱신 시간과 함께 스폰서가 반환되기를 기다리는 시간을 가져오거나 설정합니다.

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상