Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# service - communicating with service controller app

Posted on 2004-04-19
4
Medium Priority
?
1,548 Views
Last Modified: 2011-04-14
Hi,

I have an app I wrote in VB a while back that I kludged into running
as a service with srvany.  I'm now re-writing this app in C# to make
it a genuine service that's more stable and has increased
functionality.

I've written the service and the controller app, and I can start/stop
the service, etc. with no problems.

My question is this:  is it possible for my service and my controller
app to communicate?  My old application had a listbox on the main form
that showed progress notifications, etc.  I would like to mimic this
behaviour, but I don't really know where to begin with passing strings
from the service to the controller application.

Can someone point me in the right direction for this?

Thanks so much!
0
Comment
Question by:lucidity_99
4 Comments
 
LVL 4

Accepted Solution

by:
NetPointer earned 375 total points
ID: 10861891
Remoting ???
0
 
LVL 1

Assisted Solution

by:vancouver_jones
vancouver_jones earned 375 total points
ID: 10863150
So as I understand your question you have the following setup:

-An GUI Controller app running on the user desktop that is able to start/stop, etc... your Windows Service.
-A Windows Service running on the Windows Service Desktop.

And you would like to figure out a better way to communicate with your service from the user desktop.

If I remember right, a Windows Service Process cannot communicate directly with a process running on the User's desktop because the Windows Service Process is running in a seperate hidden non-gui window station. However, both the service and the front-end app share the same file system. One way that you could try to enable communication from your Service to your Controller app is to have a file somewhere that both the Service and Controller knows about. The Service modifies this file as it runs to update it with whatever changes and metadata you wish. The Controller app would then need to use FileSystemWatcher (under the System.IO namespace) class to monitor that file for changes. When a change happens, you go and read the file and have the Controller app do whatever it needs to. You will probably have to lock the file for reading and writing and have your Service and Controller wait while the file is in use by its counterpart to prevent weird syncronization problems. To have the Controller communicate with the Service, just use another file and have the Service watch for changes in it.

To do it other ways, you may need to go into unmanaged APIs. Look up "Windows Services" and "Window Stations" to learn more about how.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question