Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

ILease.CurrentState Property

Gets the current LeaseState of the lease.

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

LeaseState CurrentState { get; }
/** @property */
LeaseState get_CurrentState ()

function get CurrentState () : LeaseState

Property Value

The current LeaseState of 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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.