Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

LifetimeServices Class

Controls the.NET remoting lifetime services.

Namespace: System.Runtime.Remoting.Lifetime
Assembly: mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)] 
public sealed class LifetimeServices
/** @attribute ComVisibleAttribute(true) */ 
public final class LifetimeServices
ComVisibleAttribute(true) 
public final class LifetimeServices

Distributed garbage collection is responsible for controlling the lifetimes of server applications, and for deleting them when their lifetimes have expired. 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.

NoteNote

This class makes a link demand. A SecurityException is thrown if the immediate caller does not have infrastructure permission. See Link Demands for more information.

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

System.Object
  System.Runtime.Remoting.Lifetime.LifetimeServices

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft