This documentation is archived and is not being maintained.

How to: Override the InitializeLifetimeService Interface

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the  Windows Communication Foundation (WCF).

This code example demonstrates a standard override the InitializeLifetimeService interface.


public class MyLifetimeControlObject: MarshalByRefObject {
   public override Object InitializeLifetimeService()
      ILease lease = (ILease)base.InitializeLifetimeService();
      if (lease.CurrentState == LeaseState.Initial)  {
         lease.InitialLeaseTime = TimeSpan.FromMinutes(1);
         lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
         lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
      return lease;

Compiling the Code

This example requires:

  • References to the System.Runtime.Remoting.Lifetime namespace.

See Also