Редактиране

Споделяне чрез


System.Runtime.Remoting.Lifetime Namespace

Contains classes that manage the lifetime of remote objects.

Classes

ClientSponsor

Provides a default implementation for a lifetime sponsor class.

LifetimeServices

Controls the.NET remoting lifetime services.

Interfaces

ILease

Defines a lifetime lease object that is used by the remoting lifetime service.

ISponsor

Indicates that the implementer wants to be a lifetime lease sponsor.

Enums

LeaseState

Indicates the possible lease states of a lifetime lease.

Remarks

Traditionally, distributed garbage collection uses reference counts and pinging for control over the lifetime of objects. This works well when there are a few clients per service, but doesn't scale well when there are thousands of clients per service. The remoting lifetime service associates a lease with each service, and deletes a service when its lease time expires. The lifetime service can take on the function of a traditional distributed garbage collector, and it also adjusts well when the numbers of clients per server increases.

Each application domain contains a lease manager that is responsible for controlling leases in its domain. All leases are examined periodically for expired lease times. If a lease has expired, one or more of the lease's sponsors are invoked and given the opportunity to renew the lease. If none of the sponsors decides to renew the lease, the lease manager removes the lease and the object can be collected by the garbage collector. The lease manager maintains a lease list with leases sorted by remaining lease time. The leases with the shortest remaining time are stored at the top of the list.