GUI和windows服务通信 [英] GUI and windows service communication

查看:57
本文介绍了GUI和windows服务通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道从 Vista 开始,C# 无法将 UI 表单直接挂接到 Windows 服务.这是在 Microsoft 网站上声明的.

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

我在这方面的问题是:从 UI 到服务的最佳通信模式是什么?"

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

我听说过远程处理、Web 服务和直接 TCP.还有其他方法吗?它们与前面提到的方法相比如何?实施起来有多复杂?

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?

我的应用程序用于 Intranet,而不是 Internet.Microsoft 平台将在双方,因此互操作性不是一个因素,但速度才是.我的意思是我想通过网络上尽可能小的数据包.

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

推荐答案

如果您打算使用 .NET 进行开发,请使用 WCF 用于进程间通信.WCF 极大地简化了开发,因为与特定通信机制(例如,套接字、管道等)相关的复杂性被抽象为统一的编程模型.因此,无论您选择使用 http、tcp 还是命名管道作为传输机制,编程模型都是相同的.

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.

我强烈推荐 Juval Lowy 的书 ProgrammingWCF 服务适用于 WCF 的所有内容.您还可以访问他的网站 IDesign.net,获取免费的 WCF 代码示例.

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.

有关 WCF 的概述,请在 dnrTV 上观看此免费视频.它涵盖了 WCF 的用途,并通过一些易于理解的示例演示了 WCF 编程.

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.

如果您还没有创建您的 Windows 服务但计划在 C# 中创建,您可以按照分步操作 此处.

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

这篇关于GUI和windows服务通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆