共用方式為


HOW TO:更新租用期

如下列程式碼範例所示,這個程式碼會取得租用期並將租用期直接延長。

範例

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 命名空間的參考。

請參閱

概念

更新租用期

Footer image

Copyright © 2007 by Microsoft Corporation. All rights reserved.