将消息从Windows服务传递到Windows窗体应用 [英] Pass message from windows service to a windows form app

查看:99
本文介绍了将消息从Windows服务传递到Windows窗体应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!
我正在开发一个Windows窗体应用程序,该应用程序需要在线显示Windows服务处理的信息.换句话说,要将消息从Windows服务传递到Windows窗体应用程序.

Hello!
I am developing a windows form application that need to show information processed by a windows service online. In other words, to pass messages from the windows service to the windows form application.
How can i do that using wcf?

推荐答案

这个问题太笼统了.它主要取决于Windows服务以及WCF的托管方式.最简单的情况是由服务自行托管.

您需要从头开始:
http://msdn.microsoft.com/en-us/library/dd456779.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms731067.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms731758.aspx [ ^ ]

我在这里看到了一个很好的CodeProject示例…:简单的WCF托管和使用 [来自同一端口号的多个客户端 [
This Question is too general. It mostly depends on the Windows Service and on how WCF is hosted. Most simple case is when it is self-hosted by the Service.

You need to start from the very beginning:
http://msdn.microsoft.com/en-us/library/dd456779.aspx[^]
http://msdn.microsoft.com/en-us/library/ms731067.aspx[^]
http://msdn.microsoft.com/en-us/library/ms731758.aspx[^]

I saw a good CodeProject sample… here: Simple WCF Hosting and Consuming[^].


To answer the follow-up Question: sending data from Service to client goes beyond the client-server paradigm and may mean some kind of published-subscriber schema.
Please also take a look at my Answer to this Question:
Multple clients from same port Number[^].
Unfortunately, in that page we discussed much lower-level networking (however, who knows, maybe it will suit you as well as this approach is more flexible and not too hard to use). At the same time, I describe a skeleton of the application with the threading schema, which is the most important key to such designs.

—SA


除了SAKryukov提供的链接之外,您可能还会发现以下有趣的内容:
WCF/WPF聊天应用程序 [ WCF:双重操作和UI线程 [
Apart from the links provided by SAKryukov, you may find the following of some interest:
WCF / WPF Chat Application[^]

WCF: Duplex Operations and UI Threads[^]

Using the approach outlind in the articles you should be able to create applcations that will be able to receive notifications from the service :)

Best regards
Espen Harlinn


这篇关于将消息从Windows服务传递到Windows窗体应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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