Re: Synchronized objects
From: Ken Kolda (ken.kolda_at_elliemae-nospamplease.com)
Date: 01/28/05
- Next message: Ken Kolda: "Re: TCP Listener Problem"
- Previous message: Roger Crawfis: "Re: Asychronous events and rendering contexts"
- In reply to: Roger Crawfis: "Synchronized objects"
- Next in thread: Roger Crawfis: "Re: Synchronized objects"
- Reply: Roger Crawfis: "Re: Synchronized objects"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 27 Jan 2005 18:47:32 -0800
What you've seen so far probably mostly involves either using a config file
or the RemotingConfiguration class's static methods to identify certain
types as remoted. This is nice when you want transparency in your code as to
the source of the object -- you simply call "new MyObject()" and the
remoting system instantiates the object remotely for you. However, as you
noticed, it applies to all instances of a type, which, in your case, is not
what you want.
Luckily, there are other ways to instantiate remote objects that are
instance-specific (e.g. Activator.GetObject() and
Activator.CreateInstance()). In fact, there are several ways to get local
proxies to remote objects and the appropriate one to use depends on how you
plan to use the object in your clients and on your server. In your case, the
two main relevant questions are:
1) Does every client that connects need to access the same Foo instance
(foo4 in your case) or is each client going to be accessing its own, unique
instance of Foo on the server?
2) Does the server need to be able to access or receive events from the Foo
instances that are accessed by your client apps?
If you can answer those questions, I can steer you in the right direction
for how to set up your remoting framework.
Ken
"Roger Crawfis" <rcrawfis@columbus.rr.com> wrote in message
news:w78Kd.61443$re1.3177@fe2.columbus.rr.com...
>
> OK. I am a little lost on reading thru all of the rather simple examples
for
> remoting. It appears as if everything in .NET is type based, rather than
> instance based. I want a simple demo to synchronize a particular instance
of
> an object. Consider this simple scenario. I have a type foo, which has a
> public method bar. On my client, i want to create a local instance of foo,
> called foo1 which is totally disjoint from the server. I also want a
second
> instance of foo, foo2, which is a proxy to an instance on the server.
Assume
> the server also has two instances, foo3 and foo4. What I want is to attach
> foo2 to foo4. Everything else is a local vaiable. Do I need to create an
> entirely new component (type) to have remoting work properly? Any pointers
> to a simple example that allows this Calling foo1.bar() should be local,
but
> calling foo2.bar() should use the remote state. I do not particularly care
> at this moment, whether it copies over the remote object
(client-activated)
> or passes the method invocation to the server. In summary, I want
>
> foo foo1 = new foo(); // local instance
> foo foo2;
> foo2 = proxy for remote.foo4 instance;
>
> Roger
>
>
- Next message: Ken Kolda: "Re: TCP Listener Problem"
- Previous message: Roger Crawfis: "Re: Asychronous events and rendering contexts"
- In reply to: Roger Crawfis: "Synchronized objects"
- Next in thread: Roger Crawfis: "Re: Synchronized objects"
- Reply: Roger Crawfis: "Re: Synchronized objects"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|