NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Lease Based Lifetime Reference

MarshalByRefObject Reference

MarshalByRefObject provides some methods to work with lifetime.

public MarshalByObject
{
  public Object GetLifetimeService();
  public virtual Object InitializeLifetimeService();
}

GetLifetimeService

This method is used return a lifetime service object that is used to control the lifetime policy to the object. For the default Lifetime service this will be an object of type ILease.

Return Object to control lifetime Service.

InitializeLifetimeService

This method is used return lifetime service object. This method can be overridden to return a LifetimeService object with properties unique to this object. For the default Lifetime service this will be an object of type ILease.

Return: Object to control lifetime Serivice

ILease Reference

The ILease interface contains the publicly callable methods in the Lease class.

public interface ILease
{
    void Register(ISponsor obj, TimeSpan renewalTime);
    void Register(ISponsor obj);
    void UnRegister(ISponsor obj);
    TimeSpan Renew(TimeSpan renewalTime);

    TimeSpan RenewOnCallTime {get; set;}
    TimeSpan SponsorshipTimeout {get; set;}
    TimeSpan InitialLeaseTime {get; set;}
    TimeSpan CurrentLeaseTime {get;}      
    LeaseState CurrentState {get;}
}

Register

Register a sponsor for the lease with a renewal time.

Register

Register a sponsor for the lease with no renewal time.

UnRegister

Unregister a sponsor for the leae.

Renew

Renew the lease for the specified time.

RenewOnCallTime

The renew on call time for the lease.

SponsorshipTimeout

The sponsorship timeout for the lease.

InitialLeaseTime

The initial lease time.

CurrentLeaseTime

The current lease time.

CurrentState

The current lease state.

ISponsor Reference

Each sponsor supports the ISponsor interface. It is used by the LDGC to call back to the Sponsor.

interface ISponsor
{
   TimeSpan Renewal();
}

Renewal

The LDGC asks a sponsoring client to renew the lease for the specified service. The sponsor returns the additional lease time.

LeaseState Enum Reference

Lease States.

public enum LeaseState
{
  Null = 0,
  Initial = 1,
  Active = 2,
  Renewing = 3,
  Expired = 4,
}

Null

The lease is not initialized.

Initial

Lease has been created, but not yet active.

Active

The lease is active and has not expired.

Renewing

Lease has expired and is looking for sponsorship.

Expired

Lease has expired and cannot be renewed.

LifetimeServices Reference

Used to set and get lifetime settings. Time set for an AppDomain. They must be set before the first lease is created (the first object is marshaled which creates a lease).

public class LifetimeServices
{
    public static TimeSpan LeaseTime {get;set}
    public static TimeSpan RenewOnCallTime {get;set}
    public static TimeSpan SponsorshipTimeout {get;set}
    public static TimeSpan LeaseManagerPollTime {get;set}
}

LeaseTime

Initial Lease Time span for appdomain. Default 5 minutes.

RenewOnCallTime

Initial renew on call time span for appdomain. Default 2 minutes.

SponsorshipTimeout

Initial sponsorshiptimeout for appdomain. Default 2 minutes.

LeaseManagedPollTime

Initial sponsorshiptimeout for appdomain. Default 10 seconds.