LifetimeServices 클래스

정의

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

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 됩니다. 참조 링크 요구가 자세한 내용은 합니다.

생성자

LifetimeServices()
사용되지 않습니다.
사용되지 않습니다.

LifetimeServices의 인스턴스를 만듭니다.

속성

LeaseManagerPollTime

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

LeaseTime

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

RenewOnCallTime

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

SponsorshipTimeout

임대 갱신 시간과 함께 스폰서가 반환될 때까지 임대 관리자가 대기할 시간을 가져오거나 설정합니다.

메서드

Equals(Object)

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

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

기본 해시 함수로 작동합니다.

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상