如何:续订租约

本主题介绍一项传统技术,保留该技术是为了向后兼容现有的应用程序,不建议对新的开发使用该技术。现在应该使用  Windows Communication Foundation (WCF) 来开发分布式应用程序。

此代码获得一个租约,并像下面的代码示例所演示的那样直接延长该租约。

示例

Dim obj As New RemoteType()
Dim lease As ILease = CType(RemotingServices.GetLifetimeService(obj), ILease)
Dim expireTime As TimeSpan = lease.Renew(TimeSpan.FromSeconds(20))
RemoteType obj = new RemoteType();
ILease lease = (ILease)RemotingServices.GetLifetimeService(obj);
TimeSpan expireTime = lease.Renew(TimeSpan.FromSeconds(20));

编译代码

此示例需要:

  • System.Runtime.Remoting.Lifetime 命名空间的引用。

另请参见

概念

续订租约

生成日期:2010-02-13