I’ve created a object that inherits from MarshalByRefObject and ISponsor. In my implementation of ISponsor I just return a timespan to indicate how long I want the object renewed for.
When I call InitializeLifetimeService() to get an ILease reference to be passed into my ISponsor object it never appears to be used from examples I’ve seen.
ISponsor just seems to return a TimeSpan without actually using the ILease reference. But I’m sure there is more going on here since remoting is involved.
How do ISponsor and ILease work, specifically in terms of object lifetime renewal?
In parent AppDomain you obtain ILease object by either
InitializeLifetimeServiceorGetLifetimeServicecall with proxy instance of object in the new AppDomain. You never need to implementILeaseyourself (outside of testing yourISponsorimplementation).Than you register your custom Sponsor object which implements
ISponsorwithILease.Registercall and configureILeaseobject with timeouts.When your Sponsor object get called with
Renewalyou can say how long to keep the object alive and also may adjust/display properties of passed inILeaseinstance.