Mark,
Generally, over remoting, I think events are a bad idea. The reason for
this is that the thing firing the event has to have type information about
the types that the methods are attached to.
For what you want to do, I would create an interface which has the
callback methods on that. Then, implement that interface on an object which
has events that are fired when the methods on the interface implementation
are fired. The object also has to derive from MarshalByRefObject. Finally,
house this object in a separate assembly, so that the client and main app
can share it.
Then, from your clients, have then attach their event handlers to the
shim, and then pass the shim to your main application, which accepts the
interface (this way, it marshals calls back to the interface implementation,
and it has all the type information it needs).
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Mark Overstreet said:
I think there was some confusion...the main application will raise events
to
each remote client. Think about a VB6 client app automating Word. Word
can
fire events back to that application and this is what I am trying to
design
using Remoting and C#. If I the concept of ActiveX exe had been supported
in
C#/.NET I don't think that I would be needing any help.
Thanks.
Nicholas Paldino said:
Mark,
I think that having the central application listen on the events of
all
the clients is a bad idea. Rather, it would be cleaner if you just
exposed
methods on the central application that are called when the events on the
client are fired, and then have the event handlers on the client call the
events on the central application through remoting.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
message I am writing an app that needs to contain an object model that allows it
to
be controlled similiar to something like Word. However, I am writing
this
in
C# and all managed code. I know that I can use remoting to talk to the
UI
components but I need an example of how to create an event when
something
happens on the UI (e.g. text box receives focus) and fire that via my
object
model back to any remote client.
I also need the ability to create one central Application object that
all
remoting clients would use.
Any ideas or sample code on how to do these things?
Thanks
Mark