LifetimeServices Class

 

Controls the.NET remoting lifetime services.

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

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

<SecurityCriticalAttribute>
<ComVisibleAttribute(True)>
Public NotInheritable Class LifetimeServices

NameDescription
System_CAPS_pubmethodLifetimeServices()

Obsolete.Creates an instance of LifetimeServices.

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticLeaseManagerPollTime

Gets or sets the time interval between each activation of the lease manager to clean up expired leases.

System_CAPS_pubpropertySystem_CAPS_staticLeaseTime

Gets or sets the initial lease time span for an AppDomain.

System_CAPS_pubpropertySystem_CAPS_staticRenewOnCallTime

Gets or sets the amount of time by which the lease is extended every time a call comes in on the server object.

System_CAPS_pubpropertySystem_CAPS_staticSponsorshipTimeout

Gets or sets the amount of time the lease manager waits for a sponsor to return with a lease renewal time.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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.

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

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

SecurityPermission

for operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission Value: SecurityPermissionFlag.Infrastructure

.NET Framework
Available since 1.1

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

Return to top
Show: