[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Remote object used by 2 client

Dieter De Preester

10/8/2004 8:48:00 AM

Hello


Is there a way to write a server activated object with singleton object mode
where only 2 client have a reference to the object. I am writing a
application where a remote object may only be shared bij 2 clients.
When a third clients comes in, he has to make a new instance of the object.

kind regards

Dieter De Preester





1 Answer

Ken Kolda

10/8/2004 7:49:00 PM

0

There is no built-in way to do this. You could create a singleton factory
with a method such as GetSharedObject() which returns an instance of the
shared class and, on every other call, creates a new instance. For example:

public class ObjectServer : MarshalByRefObject
{
SharedObject currentObject = null;

public SharedObject GetSharedObject()
{
lock (this)
{
if (this.currentObject == null)
{
this.currentObject = new SharedObject();
return this.currentObject;
}
else
{
SharedObject temp = this.currentObject;
this.currentObject = null;
return temp;
}
}
}
}


Ken

"Dieter De Preester" <dieter.de.preester@howest.be> wrote in message
news:uomQ1NRrEHA.3256@TK2MSFTNGP10.phx.gbl...
> Hello
>
>
> Is there a way to write a server activated object with singleton object
mode
> where only 2 client have a reference to the object. I am writing a
> application where a remote object may only be shared bij 2 clients.
> When a third clients comes in, he has to make a new instance of the
object.
>
> kind regards
>
> Dieter De Preester
>
>
>
>
>