Groups | Blog | Home
all groups > dotnet remoting > december 2004 >

dotnet remoting : How do I send an event from Windows service to a client application


Ken Kolda
12/31/2004 12:44:22 PM
Take a look at this sample code:

http://www.bearcanyon.com/dotnet/#RemoteEvents

As you've noted, in order for your client to subscribe to the events, the
class that defines the events must be in a shared assembly used by both the
client and the windows service. Generally every remoting project will have
at least three assemblies:

1) The client application/assembly.
2) The server application/assembly.
3) The shared remoting interfaces/classes assembly.

The shared assembly will generally contain:

1) The definitions of any serializable classes used by both client and
server.
2) Either the class definitions or simply interface definitions for your
MarshalByRefObject-derived classes. (Remote events would always be defined
on a MBR class, so they would be in here also).

The sample code should help you out. If you run into any snags, post back.

Good luck -
Ken


[quoted text, click to view]

Trevor Braun
12/31/2004 2:26:24 PM
I have a Windows service that uses a timer and checks an ODBC datasource for
new sales order every few seconds. When the new sales order is found, I'd
like to notify a client application that the new sales order was detected.
I thought this was going to be fairly simple, but I can't get it to work.
I've tried several solutions using remoting, and examples from different web
sites, but I can't seem to get any of it working because the events are
being sent from one application to another. In VS.NET, I can't even
reference the windows service events, because they're part of an exe, not an
assembly.

Any help would be very much appreciated, however, I'm new to remoting, and I
have just a minor understanding of the sinks, channels, etc, so if you could
give me details or somewhere that I can find a good example of exactly what
I'm trying to do, I would be very, very grateful.

Thanks,
Trevor Braun


narasimha.gm NO[at]SPAM gmail.com
1/3/2005 10:19:44 PM
Hi,

If the client app is continously ruuning, what you can do is define a
remote object in the client application which implements an interface
like:
ICallback
{
void Update(object objdata);
}



Then your windows service has to create instance of this remote object
to communicate the event to your client application:
Activator.GetObject(..);

Regards
Ngm
AddThis Social Bookmark Button