ISponsor Interface
Indicates that the implementer wants to be a lifetime lease sponsor.
Assembly: mscorlib (in mscorlib.dll)
An object must implement the ISponsor interface if it needs to request a lease renewal for a particular object. An object that implements the ISponsor interface can become a sponsor by registering itself with the lease manager. The ISponsor interface is used by the lifetime service to call back to the sponsor.
Public Class MyClientSponsor Inherits MarshalByRefObject Implements ISponsor Private lastRenewal As DateTime Public Sub New() lastRenewal = DateTime.Now End Sub 'New <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 'MyClientSponsor
public __gc class MyClientSponsor : public MarshalByRefObject, public ISponsor
{
private:
DateTime lastRenewal;
public:
MyClientSponsor()
{
lastRenewal = DateTime::Now;
}
[SecurityPermissionAttribute(SecurityAction::LinkDemand, Flags=SecurityPermissionFlag::Infrastructure)]
TimeSpan Renewal(ILease* /* lease */)
{
Console::WriteLine(S"Request to renew the lease time.");
Console::WriteLine(S"Time since last renewal: {0}", __box(DateTime::Now - lastRenewal));
lastRenewal = DateTime::Now;
return TimeSpan::FromSeconds(20);
}
};
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.