Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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.

Example

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

Community Additions

ADD
Show:
© 2015 Microsoft