ILease 接口


定义远程处理生存期服务所使用的生存期租约对象。Defines a lifetime lease object that is used by the remoting lifetime service.

public interface class ILease
public interface ILease
public interface ILease
type ILease = interface
type ILease = interface
Public Interface ILease


分布式垃圾回收控制可以删除服务器应用程序的时间。Distributed garbage collection controls when server applications can be deleted. 传统上,分布式垃圾回收使用引用计数和 ping 控制。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. 租约可以指定对象具有无限生存期。A lease can specify that an object has an infinite lifetime.

每个都 AppDomain 包含一个管理域中的租约的租约管理器。Each AppDomain contains a lease manager that administers the leases in the domain. 租约管理器定期检查租约的时间是否过期。The lease manager periodically examines the leases for time expiration. 如果租约过期,则可以通过删除租约的引用来取消它,或通过调用一个或多个租约的主办方来续订。If a lease has expired, it can either be canceled by removing its reference to the lease, or renewed by invoking one or more of the lease's sponsors.

租约包含确定其策略的属性,以及用于续订租约时间的方法。A lease contains properties that determine its policies, and methods that renew the lease time. 租约公开 ILease 接口。The lease exposes the ILease interface.

有关演示如何使用接口的示例, ILease 请参阅 生存期For an example showing how to use the ILease interface see Lifetimes.



获取租约的剩余时间。Gets the amount of time remaining on the lease.


获取租约的当前 LeaseStateGets the current LeaseState of the lease.


获取或设置租约的初始时间。Gets or sets the initial time for the lease.


获取或设置对远程对象的调用续订 CurrentLeaseTime 的时间。Gets or sets the amount of time by which a call to the remote object renews the CurrentLeaseTime.


获取或设置等待主办方返回租约续订时间的时间。Gets or sets the amount of time to wait for a sponsor to return with a lease renewal time.



在不续订租约的前提下为该租约注册主办方。Registers a sponsor for the lease without renewing the lease.

Register(ISponsor, TimeSpan)

为该租约注册主办方,并将其续订指定的 TimeSpanRegisters a sponsor for the lease, and renews it by the specified TimeSpan.


将租约续订指定的时间。Renews a lease for the specified time.


从赞助商列表中删除赞助商。Removes a sponsor from the sponsor list.