How to signal an app GUI from a .NET server
-
I have an application that acts as a remoting server. The app has a front end with lots of controls, and the remoting is (as it must be) a class in a class library of its own, which is instantiated by the remoting system when a call is made by a remote client (as I understand it). I want to be able to update stuff on the screen when a remote client calls a method in the server, but I can't work out how to communicate between the server object and the rest of the application. Can anyone tell me if this is possible and how it's done. Dave
-
I have an application that acts as a remoting server. The app has a front end with lots of controls, and the remoting is (as it must be) a class in a class library of its own, which is instantiated by the remoting system when a call is made by a remote client (as I understand it). I want to be able to update stuff on the screen when a remote client calls a method in the server, but I can't work out how to communicate between the server object and the rest of the application. Can anyone tell me if this is possible and how it's done. Dave
When you setup the remoting on the server side, instead of allowing the remoting infrastructure to create server objects, create them yourself and register it using RemotingServices.Marshal[^]. You could then expose events from those objects and subscribe to them from the GUI. Something like
class RObject: MarhsalByRefObject
{
event SomethingChangedDelegate SomethingChanged;public void RemoteMethod()
{
SomethingChanged();
}
}
}class GUI
{
void RegisterRemoteObjects()
{
RObject o = new RObject();
o.SomethingChanged += ...
RemotingServices.Marshal(...);
}
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
When you setup the remoting on the server side, instead of allowing the remoting infrastructure to create server objects, create them yourself and register it using RemotingServices.Marshal[^]. You could then expose events from those objects and subscribe to them from the GUI. Something like
class RObject: MarhsalByRefObject
{
event SomethingChangedDelegate SomethingChanged;public void RemoteMethod()
{
SomethingChanged();
}
}
}class GUI
{
void RegisterRemoteObjects()
{
RObject o = new RObject();
o.SomethingChanged += ...
RemotingServices.Marshal(...);
}
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro
Thanks Senthil. I eventually found a viable solution by getting the server class to post windows messages to the GUI. However, yours is an interesting alternative which I shall investigate. I need to understand some of these more advanced remoting techniques. Thanks. Dave