This documentation is archived and is not being maintained.

ILease.InitialLeaseTime Property

Gets or sets the initial time for the lease.

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

TimeSpan InitialLeaseTime { get; set; }
/** @property */
TimeSpan get_InitialLeaseTime ()

/** @property */
void set_InitialLeaseTime (TimeSpan value)

function get InitialLeaseTime () : TimeSpan

function set InitialLeaseTime (value : TimeSpan)

Not applicable.

Property Value

The initial time for the lease.

Exception typeCondition

SecurityException

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

If the InitialLeaseTime property is set to TimeSpan.Zero, then the lease will never time out and the object associated with it will have an infinite lifetime.

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
Show: