Raise a UI (like GotFocus) event back to remoting client

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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)

Mark Overstreet said:
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
 
I think there is some confusion...I want to raise events from the main
application back to all remoting clients. Think of a vb6 application
controlling Word through automation. Word can raise events back to the vb6
client and this is what I am trying to emulate with C# and .NET. If .NET had
supported something equivalent to ActiveX Exes I don't think I would have
this problem.

Thanks
Mark

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)

Mark Overstreet said:
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
 
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)

Mark Overstreet said:
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
 
Thanks that makes sense and I'll give it a shot. However, I don't like that
because it is more work for anyone trying to automate my application. Any
chance that the new version of .NET will support events better?

Thanks.


Nicholas Paldino said:
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
 
Back
Top