Solved

C# service - communicating with service controller app

Posted on 2004-04-19
4
1,544 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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