Groups | Blog | Home
all groups > dotnet remoting > november 2003 >

dotnet remoting : Lease Timeout Event


Johan Karlsson
11/27/2003 11:12:51 PM
Hi,

I have a server that creates a singleton object of my service. When all
leases for this object is gone the object destroys itself, right?

I need to capture that event in order to save all data to disk. What is the
best practice for doing this?

Thanks
/Johan

Hasani
11/28/2003 2:38:55 AM
if this is a singleton, why not implement this code in the object's
destructor?
[quoted text, click to view]

Johan Karlsson
11/28/2003 8:01:45 AM
I have, but it doesnt seem to fire?
Is this the best practice though? What happens if the object gets disposed
and waiting for garbage collection, with finalize not called yet and another
object needs to be created. Doesn't this object get created before the first
one gets finalized?

/Johan

"Hasani" <HJB417@hotmail.c0m> skrev i meddelandet
news:3zyxb.162075$Gq.19937483@twister.nyc.rr.com...
[quoted text, click to view]

Hasani
11/28/2003 2:37:40 PM
I'm not sure how remoting works for singleton but that situation is probably
possibility. I did come across this though
http://www.dotnet247.com/247reference/msgs/28/144808.aspx .I've never heard
of the ITrackingHandler or the TrackingServices class, but since your using
a singleton, this is a better way then using the destructor. This would
probably be the best practice also =]
[quoted text, click to view]

Johan Karlsson
11/28/2003 3:56:41 PM
More info,

It seems like the objects get marked for garbage collect but the framework
puts them "onhold" for a long time. New objects gets created before the
finalizers ever gets called.

I need an event or something to tell me that this object is "leaseless" or
has no connection to the world?

Is there an event or do I have to keep the object alive through a timer and
some dummy calls?

Also, the change in timeout values doesn't seem to be working. See code
below. It gets called and every line get executed but the object times out
in less than five minutes.

Thanks

/Johan

Public Overrides Function InitializeLifetimeService() As Object

'* Lease setup

'TODO Add some variables to control these times
Dim lease As ILease = CType(MyBase.InitializeLifetimeService(),
ILease)

If (lease.CurrentState = LeaseState.Initial) Then
lease.InitialLeaseTime = TimeSpan.FromMinutes(60)
lease.RenewOnCallTime = TimeSpan.FromMinutes(30)
End If

Return lease

End Function

/Johan

"Johan Karlsson" <johannospam.karlsson@adnome.se> skrev i meddelandet
news:eK5o91XtDHA.1888@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Johan Karlsson
11/28/2003 6:38:14 PM
THANK YOU!

This is exactly what I was looking for!

/Johan

"Hasani" <HJB417@hotmail.c0m> skrev i meddelandet
news:U4Jxb.301758$pT1.80097@twister.nyc.rr.com...
[quoted text, click to view]

Sebastien Lambla
12/16/2003 9:46:26 AM
You should take a look at the ITrackingHandler and TrackingServices classes
in System.Runtime.Remoting.Services

--
Sebastien Lambla
http://thetechnologist.is-a-geek.com/blog/


"Johan Karlsson" <johannospam.karlsson@adnome.se> a écrit dans le message de
news: enxwW$btDHA.2432@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button