Results 1 to 6 of 6

Thread: Remoting objects lifetime?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234

    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

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: Remoting objects lifetime?

    VB Code:
    1. Public Overrides Function InitializeLifeTimeService() As Object
    2.       Try
    3.         Dim lease As ILease = DirectCast(MyBase.InitializeLifetimeService(), ILease)
    4.         lease.InitialLeaseTime = TimeSpan.FromHours(8)
    5.         lease.RenewOnCallTime = TimeSpan.FromMinutes(1)
    6.         lease.SponsorshipTimeout = TimeSpan.FromMinutes(1)
    7.         Return lease
    8.       Catch
    9.         ErrorMsg()
    10.       End Try
    11.     End Function

    You can set this information as in the code example above

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234

    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

  4. #4
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    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)

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Remoting objects lifetime?

    Have you tried Finalise() event instead of Dispose?
    I don't live here any more.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234

    Re: Remoting objects lifetime?

    I already tried Finalize() but with no success.

    regard j

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width