ILease.CurrentLeaseTime Property

Gets the amount of time remaining on the lease.

Namespace: System.Runtime.Remoting.Lifetime
Assembly: mscorlib (in mscorlib.dll)

TimeSpan CurrentLeaseTime { get; }
/** @property */
TimeSpan get_CurrentLeaseTime ()

function get CurrentLeaseTime () : TimeSpan

Not applicable.

Property Value

The amount of time remaining on the lease.

Exception typeCondition

SecurityException

The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.

The following example uses RemotingServices.GetLifetimeService to obtain an object that implements the ILease interface. To compile and run this example, you need the complete client, server, and shared library code found in the example for ILease.

// Register the channel.
TcpChannel myChannel = new TcpChannel ();
ChannelServices.RegisterChannel(myChannel);
RemotingConfiguration.RegisterActivatedClientType(
                       typeof(HelloService),"Tcp://localhost:8085");

TimeSpan myTimeSpan = TimeSpan.FromMinutes(10);

// Create a remote object.
HelloService myService = new HelloService();

ILease myLease;
myLease = (ILease)RemotingServices.GetLifetimeService(myService);
if (myLease == null)
{
   Console.WriteLine("Cannot lease.");
   return;
}

Console.WriteLine ("Initial lease time is " + myLease.InitialLeaseTime);
Console.WriteLine ("Current lease time is " + myLease.CurrentLeaseTime);
Console.WriteLine ("Renew on call time is " + myLease.RenewOnCallTime);
Console.WriteLine ("Sponsorship timeout is " + myLease.SponsorshipTimeout);
Console.WriteLine ("Current lease state is " + myLease.CurrentState.ToString());

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: