如何:续订租约

此代码获取租约并直接延长它,如下面的代码示例中所示。

示例

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 命名空间的引用。

请参见

概念

续订租约