System.Runtime.Remoting.Lifetime.ILease Interface

Assembly: Mscorlib.dll
Namespace: System.Runtime.Remoting.Lifetime
Summary
Defines a lifetime lease object that is used by the remoting lifetime service.
C# Syntax:
public interface ILease
Remarks
Distributed garbage collection controls when server applications can be deleted. Traditionally, distributed garbage collection uses reference counts and pinging for control. This works well when there are a few clients per object, but does not work well when there are thousands of clients per each object. The lifetime service can assume the function of a traditional distributed garbage collector, and scales well when the number of clients increases.

The lifetime service associates a lease with each remotely activated object. When the lease expires, the object is removed. A lease can specify that an object has an infinite lifetime.

Each AppDomain contains a lease manager that administers the leases in the domain. The lease manager periodically examines the leases for time expiration. If a lease has expired, it can either be canceled by removing its reference to the lease, or renewed by invoking one or more of the lease's sponsors.

A lease contains properties that determine its policies, and methods that renew the lease time. The lease exposes the ILease interface.

See also:
System.Runtime.Remoting.Lifetime Namespace

System.Runtime.Remoting.Lifetime.ILease Member List:

Public Properties
CurrentLeaseTime Read-only

Gets the amount of time remaining on the lease.
CurrentState Read-only

Gets the current LeaseState of the lease.
InitialLeaseTime Read-write

Gets or sets the initial time for the lease.
RenewOnCallTime Read-write

Gets or sets the amount of time by which a call to the remote object increases the ILease.CurrentLeaseTime.
SponsorshipTimeout Read-write

Gets or sets the amount of time to wait for a sponsor to return with a lease renewal time.
Public Methods
Register Overloaded:
Register(ISponsor obj)

Registers a sponsor for the lease without renewing the lease.
Register Overloaded:
Register(ISponsor obj, TimeSpan renewalTime)

Registers a sponsor for the lease, and renews it by the specified TimeSpan.
Renew Renews a lease for the specified time.
Unregister Removes a sponsor from the sponsor list.

System.Runtime.Remoting.Lifetime.ILease Member Details

Property: CurrentLeaseTime (read-only)
Summary
Gets the amount of time remaining on the lease.
C# Syntax:
TimeSpan CurrentLeaseTime {get;}

Return to top


Property: CurrentState (read-only)
Summary
Gets the current LeaseState of the lease.
C# Syntax:
LeaseState CurrentState {get;}
See also:
LeaseState

Return to top


Property: InitialLeaseTime (read-write)
Summary
Gets or sets the initial time for the lease.
C# Syntax:
TimeSpan InitialLeaseTime {get; set;}
Remarks
If the ILease.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.

Return to top


Property: RenewOnCallTime (read-write)
Summary
Gets or sets the amount of time by which a call to the remote object increases the ILease.CurrentLeaseTime.
C# Syntax:
TimeSpan RenewOnCallTime {get; set;}
Remarks
The lifetime service adds ILease.RenewOnCallTime to ILease.CurrentLeaseTime every time that a call is made on the object.

Return to top


Property: SponsorshipTimeout (read-write)
Summary
Gets or sets the amount of time to wait for a sponsor to return with a lease renewal time.
C# Syntax:
TimeSpan SponsorshipTimeout {get; set;}
Remarks
If the ILease.SponsorshipTimeout is TimeSpan.Zero, then this lease will not take sponsors.

If a sponsor does not respond to a call to renew a lease within the time-out period, it is assumed to be dead and is removed from the list of sponsors for the current lease.

Return to top


Overloaded Method: Register(
   ISponsor obj
)
Summary
Registers a sponsor for the lease without renewing the lease.
C# Syntax:
void Register(
   ISponsor obj
);
Parameters:

obj

The callback object of the sponsor.

Remarks
If a sponsor is registered with the current method, the lease is not renewed.

Return to top


Overloaded Method: Register(
   ISponsor obj,
   TimeSpan renewalTime
)
Summary
Registers a sponsor for the lease, and renews it by the specified TimeSpan.
C# Syntax:
void Register(
   ISponsor obj,
   TimeSpan renewalTime
);
Parameters:

obj

The callback object of the sponsor.

renewalTime

The length of time to renew the lease by.

Return to top


Method: Renew(
   TimeSpan renewalTime
)
Summary
Renews a lease for the specified time.
C# Syntax:
TimeSpan Renew(
   TimeSpan renewalTime
);
Parameters:

renewalTime

The length of time to renew the lease by.

Return Value:
The new expiration time of the lease.
Remarks
The lease time is set to the maximum of the ILease.CurrentLeaseTime or the current time plus the renewal time.

Return to top


Method: Unregister(
   ISponsor obj
)
Summary
Removes a sponsor from the sponsor list.
C# Syntax:
void Unregister(
   ISponsor obj
);
Parameters:

obj

The lease sponsor to unregister.

Return Value:
After this method is called, the lease state changes to expired and the object is collected by the garbage collector.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.