Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI and windows service communication

I know since Vista, that C# can't hook a UI form directly to the windows service. This was stated on the Microsoft Site.

My question in this regard is: "What is the best mode of communication from a UI to the service?"

I have heard of Remoting, Web services, and direct TCP. Are there other methods? How do they rank against the previously mentioned methods? How complicated are they to implement?

My application is for intranet use, not internet. Microsoft platform will be on both sides, so interoperability is not a factor, but speed is. I mean I want to get across the smallest packet possible on the network.

TIA

like image 710
Stéphane Avatar asked Nov 20 '09 20:11

Stéphane


People also ask

Can a Windows service have a GUI?

Windows services cannot have GUIs, so you will need to either get rid of the GUI or separate your application into two pieces - a service with no UI, and a "controller" application.

Can Windows service interact with desktop?

Right-click the service name, and select Properties. The Service Properties window is displayed. Select the Log On tab. Select Local System account and then select Allow service to interact with desktop.

How can a Windows service execute a GUI application?

The service communicates with the GUI application to tell it when to display the GUI. The application communicates the results of the user interaction back to the service so that the service can take the appropriate action.

What is the use of window service?

Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface.


2 Answers

If you are going to be developing with .NET, use WCF for your interprocess communication. WCF greatly simplifies development because the intricacies associated with a specific communication mechanism (e.g., sockets, pipes, etc.) are abstracted behind a unified programming model. Thus, it doesn't matter if you choose to use http, tcp, or named pipes for your transport mechanism, the programming model is the same.

I would highly recommend Juval Lowy's book Programming WCF Services for all things WCF. You can also visit his website, IDesign.net, for free WCF code samples.

For an overview of WCF, watch this free video at dnrTV. It covers the purpose of WCF and demonstrates WCF programming through some easy-to-follow examples.

If you have not already created your Windows service but plan to do so in C#, you can follow the step-by-step here.

like image 153
Matt Davis Avatar answered Sep 19 '22 10:09

Matt Davis


There are many ways to communicate between processes - named pipes, mailslots, memory mapped files, sockets, ActiveX/COM objects, just to name a few. It really boils down to which technologies you are familiar/comfortable with.

like image 41
Remy Lebeau Avatar answered Sep 20 '22 10:09

Remy Lebeau