Solved

C# service - communicating with service controller app

Posted on 2004-04-19
4
1,531 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 125 total points
ID: 10861891
Remoting ???
0
 
LVL 1

Assisted Solution

by:vancouver_jones
vancouver_jones earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dynamic menu in asp.net c# 11 55
Memory Usage 2 49
Linq Help 1 33
LINQ - C# to VB convertion 12 45
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
A short film showing how OnPage and Connectwise integration works.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now