Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# service - communicating with service controller app

Posted on 2004-04-19
4
Medium Priority
?
1,546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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