By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,198 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,198 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:52**********************************@microsof t.com...
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

Nov 16 '05 #2

P: n/a
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:52**********************************@microsof t.com...
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


Nov 16 '05 #3

P: n/a
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:52**********************************@microsof t.com...
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


Nov 16 '05 #4

P: n/a
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]
- mv*@spam.guard.caspershouse.com
"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:FF**********************************@microsof t.com...
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:52**********************************@microsof t.com...
>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
>


Nov 16 '05 #5

P: n/a
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com
"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:FF**********************************@microsof t.com...
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Mark Overstreet" <Ma************@discussions.microsoft.com> wrote in
message news:52**********************************@microsof t.com...
>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
>


Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.