Communicating windows service with windows app: remoting?

  • Thread starter Thread starter Diego F.
  • Start date Start date
D

Diego F.

Hello. I have a windows service running that listens to a port and makes
insert queries in a database.

I need to make an interface, so my idea is creating a simple windows
application that just shows messages from the service.

Can I do that with remoting? What are the main steps to do that?
 
One way i can recommend is while the windows service is processing, let it
write onto event viewer. So that you can use the windows app to read the
messages from Event viewer on a perioding intervels.

HTH
 
Diego F. said:
Hello. I have a windows service running that listens to a port and makes
insert queries in a database.

I need to make an interface, so my idea is creating a simple windows
application that just shows messages from the service.

Can I do that with remoting? What are the main steps to do that?

Sure you can, and you can also use WCF (V3 of the Framework).
When using local cross-process remoting, your best bet is to use the
"IpcServerChannel".
Implement the "server side" in your Windows application and make sure it
runs on a thread separated from the UI thread, keep in mind to marshal the
calls when updating the UI. Your Service simply acts as a remoting client.
Search MSDN, it sure contains some simple samples to give you an head start.

Willy.
 
Chakravarthy said:
One way i can recommend is while the windows service is processing, let it
write onto event viewer. So that you can use the windows app to read the
messages from Event viewer on a perioding intervels.

That looks easy. I can try that. Thank you for your idea. The only issue is
that won't be in real time.
 
Willy Denoyette said:
Sure you can, and you can also use WCF (V3 of the Framework).
When using local cross-process remoting, your best bet is to use the
"IpcServerChannel".
Implement the "server side" in your Windows application and make sure it
runs on a thread separated from the UI thread, keep in mind to marshal the
calls when updating the UI. Your Service simply acts as a remoting client.
Search MSDN, it sure contains some simple samples to give you an head
start.

Willy.

Then, just to identify the scenario, according to the MSDN help I need:

A remotable object.
A host application domain to listen for requests for that object.
A client application domain that makes requests for that object.

You suggest that the client is the service and the host is the windows app.
Which is the remotable object?
 
Diego F. said:
Then, just to identify the scenario, according to the MSDN help I need:

A remotable object.
A host application domain to listen for requests for that object.
A client application domain that makes requests for that object.

You suggest that the client is the service and the host is the windows
app.
Which is the remotable object?

--

Regards,

Diego F.


The "remotable object", is the object you want to pass from the client to
the server, for instance the service state information (what you called
"messages from the service") you want to pass from your service to the
Windows application. This object must derive from MarshalByRefObject and
implement a common interface.

Willy.
 
Diego F. said:
Hello. I have a windows service running that listens to a port and makes
insert queries in a database.

I need to make an interface, so my idea is creating a simple windows
application that just shows messages from the service.

Can I do that with remoting? What are the main steps to do that?

Why don't you look up how to do a Service OnCustomCommand event, which can
be done from a Windows Desktop application that's communicating with the
service?

The OnCustomCommand event gathers your messages from the service, which
could be held in an array, writes the data to a text file in a directory,
the Windows Desktop application, detects this file's presence and displays
the data in a Listbox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top