Solved

C# service - communicating with service controller app

Posted on 2004-04-19
4
1,528 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
Comment Utility
Remoting ???
0
 
LVL 1

Assisted Solution

by:vancouver_jones
vancouver_jones earned 125 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows phone Development 11 27
c# string 6 39
C# System Cannot Find File Specified Error 4 55
optimize  c# code 7 48
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

12 Experts available now in Live!

Get 1:1 Help Now