[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Server component instances

Pedro Gago

11/5/2004 2:36:00 PM

Hi everybody,

I'm doing tests with the server activation methods: singlecall and
singleton.
My test is (from the client point of view): I open the channel (TCP), I do
10 calls to a server component function and I close the channel. But here
there are the problems:

1) I have writen code in the server component constructor (Sub New). This
code only writes something in the console. The question is that for each
client call the constructor funtion is executed, so I can see 10 times the
text in the console. In my opinion I have only to see once this text.
(Obviously, I don't create a new instance of the server component in the
client each time)

2) The result with one client is that the first call need more time that the
rest. That's ok because I've read that is in the first call that the
instance in the server is created. But what happens when two clients,
executing them at the same time, use the same server component with
Singleton? My result is that in both clients there are a large time for the
first call. In my oponion (reading the documentation) only one instance is
created when we use Singleton, so I don't understand why both clients return
more or less the same time in its first call.

Thanks

Pedro Gago


1 Answer

Ken Kolda

11/5/2004 4:20:00 PM

0

See comments inline below...

"Pedro Gago" <pgago_y@yahoo.es> wrote in message
news:O$eSvH0wEHA.1404@TK2MSFTNGP11.phx.gbl...
> Hi everybody,
>
> 1) I have writen code in the server component constructor (Sub New). This
> code only writes something in the console. The question is that for each
> client call the constructor funtion is executed, so I can see 10 times the
> text in the console. In my opinion I have only to see once this text.
> (Obviously, I don't create a new instance of the server component in the
> client each time)
>

This is the expected behavior if your object is defined as SingleCall. Every
property/method invocation on a single call object causes a new instance to
be instantiated. If you were using a singleton, you should only see the
constructor invoked once (unless the object's lease expires after some
period of inactivity, in which case a new singleton would be created). You
may be confusing a SingleCall object with a client-activated object (CAO).
CAOs allow each client to have its own instance which it can invoke just
like a normal object (i.e. a new instance is not constructed for each method
call). If you haven't done so already, be sure to read the MSDN information
on object activation:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconacti...


> 2) The result with one client is that the first call need more time that
the
> rest. That's ok because I've read that is in the first call that the
> instance in the server is created. But what happens when two clients,
> executing them at the same time, use the same server component with
> Singleton? My result is that in both clients there are a large time for
the
> first call. In my oponion (reading the documentation) only one instance is
> created when we use Singleton, so I don't understand why both clients
return
> more or less the same time in its first call.

The reason the first call needs more time isn't because of the object being
constructed on the server, it's because the first call is when the client
opens the network connection to the server. So, all clients will experience
this delay since each client must open its own connection.

Ken