Remoting objects lifetime?
Hi,
I created a singleton object using .NET Remoting. The object is created in a .NET remoting server and the same instance is marshaled to the client when the client creates a new object of it. In constructor (public Sub New()) I have writeLog() function, that function create txt file and write time when object created. I implement IDisposable interface where I again call writeLog() function to write time when object destroyed.
When object is created I see line in txt file with time of creation, but I can't get time when object destoyes. I think that by default lifetime of singleton server activated objects is 5min. after there is no calls from clients and then garbage collector delete objects from memory. Or in other words how to get time when object destroyes?
regard j
Re: Remoting objects lifetime?
VB Code:
Public Overrides Function InitializeLifeTimeService() As Object
Try
Dim lease As ILease = DirectCast(MyBase.InitializeLifetimeService(), ILease)
lease.InitialLeaseTime = TimeSpan.FromHours(8)
lease.RenewOnCallTime = TimeSpan.FromMinutes(1)
lease.SponsorshipTimeout = TimeSpan.FromMinutes(1)
Return lease
Catch
ErrorMsg()
End Try
End Function
You can set this information as in the code example above
Re: Remoting objects lifetime?
With that code I get lifetime data for object but still I can't get time when object destroyed?
regard j
Re: Remoting objects lifetime?
I am not sure you can get the time when the object is actually destroyed. This depends upon when Garbage Collection is initiated, and you have no control over this (unless you call object.Dispose, object = Nothing, or GC.Collect)
Re: Remoting objects lifetime?
Have you tried Finalise() event instead of Dispose?
Re: Remoting objects lifetime?
I already tried Finalize() but with no success.
regard j