LifetimeServices クラス
.NET リモート処理有効期間サービスを制御します。
この型のすべてのメンバの一覧については、LifetimeServices メンバ を参照してください。
System.Object
System.Runtime.Remoting.Lifetime.LifetimeServices
NotInheritable Public Class LifetimeServices
[C#]
public sealed class LifetimeServices
[C++]
public __gc __sealed class LifetimeServices
[JScript]
public class LifetimeServices
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
配布されたガベージ コレクションは、サーバー アプリケーションの有効期間を制御し、有効期限が切れた場合にいつサーバー アプリケーションを削除するかを制御する役割を果たします。従来、配布されたガベージ コレクションは、制御のために参照カウントと ping を使用していました。この方法は、オブジェクトごとのクライアント数が少ない場合には機能しますが、千単位のクライアント数の場合にはうまく機能しません。有効期間サービスは、従来の配布されたガベージ コレクタの機能を実行できます。さらに、クライアント数が増加した場合にも対応できます。
有効期間サービスは、リモートの各アクティブ化オブジェクトにリースを関連付けます。リースの有効期限が切れると、オブジェクトが削除されます。
メモ このクラスはリンク確認要求を行います。直前の呼び出し元にインフラストラクチャ アクセス許可がない場合、SecurityException がスローされます。詳細については、「 リンク確認要求 」を参照してください。
使用例
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http
Imports System.Runtime.Remoting.Lifetime
Public Class Server
Public Shared Sub Main()
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))
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 'Main
End Class 'Server
[C#]
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() {
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));
RemotingConfiguration.RegisterActivatedServiceType(typeof(ClientActivatedType));
Console.WriteLine("The server is listening. Press Enter to exit....");
Console.ReadLine();
Console.WriteLine("GC'ing.");
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
[C++]
#using <mscorlib.dll>
#using <system.dll>
#using <system.runtime.remoting.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(new HttpChannel(8080));
RemotingConfiguration::RegisterActivatedServiceType(__typeof(ClientActivatedType));
Console::WriteLine(S"The server is listening. Press Enter to exit....");
Console::ReadLine();
Console::WriteLine(S"GC'ing.");
GC::Collect();
GC::WaitForPendingFinalizers();
return 0;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Runtime.Remoting.Lifetime
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: Mscorlib (Mscorlib.dll 内)
.NET Framework セキュリティ:
- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)要求値: SecurityAction.LinkDemand; アクセス許可値: SecurityPermissionFlag.Infrastructure
参照
LifetimeServices メンバ | System.Runtime.Remoting.Lifetime 名前空間