ISponsor.Renewal(ILease) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Requests a sponsoring client to renew the lease for the specified object.
public:
TimeSpan Renewal(System::Runtime::Remoting::Lifetime::ILease ^ lease);
public TimeSpan Renewal (System.Runtime.Remoting.Lifetime.ILease lease);
[System.Security.SecurityCritical]
public TimeSpan Renewal (System.Runtime.Remoting.Lifetime.ILease lease);
abstract member Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
[<System.Security.SecurityCritical>]
abstract member Renewal : System.Runtime.Remoting.Lifetime.ILease -> TimeSpan
Public Function Renewal (lease As ILease) As TimeSpan
Parameters
- lease
- ILease
The lifetime lease of the object that requires lease renewal.
Returns
The additional lease time for the specified object.
- Attributes
Exceptions
The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.
Examples
public ref class MyClientSponsor: public MarshalByRefObject, public ISponsor
{
private:
DateTime lastRenewal;
public:
MyClientSponsor()
{
lastRenewal = DateTime::Now;
}
[SecurityPermissionAttribute(SecurityAction::LinkDemand,Flags=SecurityPermissionFlag::Infrastructure)]
virtual TimeSpan Renewal( ILease^ /* lease */ )
{
Console::WriteLine( "Request to renew the lease time." );
Console::WriteLine( "Time since last renewal: {0}",
DateTime::Now - lastRenewal );
lastRenewal = DateTime::Now;
return TimeSpan::FromSeconds( 20 );
}
};
public class MyClientSponsor : MarshalByRefObject, ISponsor
{
private DateTime lastRenewal;
public MyClientSponsor()
{
lastRenewal = DateTime.Now;
}
public TimeSpan Renewal(ILease lease)
{
Console.WriteLine("Request to renew the lease time.");
Console.WriteLine("Time since last renewal: " +
(DateTime.Now - lastRenewal).ToString());
lastRenewal = DateTime.Now;
return TimeSpan.FromSeconds(20);
}
}
Public Class MyClientSponsor
Inherits MarshalByRefObject
Implements ISponsor
Private lastRenewal As DateTime
Public Sub New()
lastRenewal = DateTime.Now
End Sub
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Function Renewal(lease As ILease) As TimeSpan Implements ISponsor.Renewal
Console.WriteLine("Request to renew the lease time.")
Console.WriteLine("Time since last renewal: " + _
DateTime.op_Subtraction(DateTime.Now, lastRenewal).ToString())
lastRenewal = DateTime.Now
Return TimeSpan.FromSeconds(20)
End Function 'Renewal
End Class
Remarks
The Renewal method is called by the distributed garbage collector to renew the lease for the specified object.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈