Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / September 2004

Tip: Looking for answers? Try searching our database.

Lifetime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick Jox - 30 Sep 2004 06:05 GMT
Hi,
I trying to find a solution for lifetime of the server object. I do not want
to override the InitializeLifeTimeServices by a method that returns null, so
that the object lives forever. My problem is, that I can create the remote
object by the client and register event procedures. Then everything works
until by time of no action, the remote object will be distroyed.
As far as I understood, the remote object is really instanced on the server,
when it is the first time accessed (property or method). So when I access
the object by the client application by calling a method, it works again.
But all my event listeners do not receive any event.
I can now register a sponsor to do that but does this really solve my
problem?
I would find it very smart, if there was a possibilty if i could check if
the server object is still alive and if not registering again my event
listeners. Is there a possibility to achieve this?

Thanks - Patrick
Ryan  Berry - 30 Sep 2004 14:52 GMT
Patrick,

Sounds like you've discovered the method that remoting services uses
to maintain it's connection.  Without lifetime management, the runtime
would not be able to know when it's "safe" to tear down the expensive
connection between the app-domains.  While this method is (IMHO) nicer
than the ref-counting method used in COM+, it does present some
limitations; of which you have discovered.  If you have a class-factory
creating new objects to "clients", you would most definitly not want
them to persist forever.  (In this case, memory would never be relased,
even when the "client" disconnects!)  We ran into a a simliar (but
different ... aren't they always that way?) design hurdle with a recent
project for a client of ours.  We had a "client" (I'm using the terms
loosely, as in the case of events, the client actually acts as a server
when the callback is invoked.  Anytime I refer to the client, I'm
meaning the application you wish the other process to invoke delegates
on.)  application that we wanted to be aware of the "server" process'
state.  It needed to re-register the callbacks upon a disconnection
(the other machine was power cycled, network problems...or *gasp* a
blue screen on the server...but that never happens) and thus needed to
"monitor" the connection.  What we did was setup a ping method on the
"server", which would do nothing more than turnaround and invoke a
delegate on the "client".  If we did not get a callback within some
reasonable threshold of time, we'd terminate our remoting channel,
reconnect to the "server" and register our callbacks again.  Something
like this:

Client-->Calls Ping method on server-->Waits...
Server-->Invokes callback on client
Client--<Starts process over again

This allowed us to know when the callback stopped working, as
(depending on the remoting confiuration) you could actually get a "new"
object from the "server" if your lifetimeservices timeout was reached.
Also, we ended up having to programatically control remoting in lieu of
the [app].config file, as you do not have the ability to explicitly
control the channel when using config files to set things up.

I would also examine the thread sync handles
(system.threading.waithandle) to wait for the server to reply within
the "worker thread" in the client!
Hope this helps.

         -- Ryan Berry
Ken Kolda - 30 Sep 2004 19:16 GMT
It sounds like you have an SAO which is raising events. Is there a reason
you don't want to implement this as a singleton that lives forever?

Ken

> Hi,
> I trying to find a solution for lifetime of the server object. I do not want
[quoted text clipped - 13 lines]
>
> Thanks - Patrick

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.