dot net 中 windows 服务的 UI [英] UI for windows service in dot net

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

问题描述

我在 dot net 中创建了一个 Windows 服务来自动向我的朋友发送电子邮件.一切正常.现在我有一个要求,比如显示一个弹出窗口,上面写着邮件已经发送或类似的东西.但是我需要一些想法来实现该逻辑.我认为 Windows 服务不可能有 UI.所以我想创建另一个 Windows 应用程序来显示弹出消息,并在邮件发送后从 Windows 服务调用它.这只是想法,不确定这种方法是否正确.请指导我.

I was creating a windows service in dot net to send automatic email to my friends. All is working well. Now I have a requirement like to show a pop up which says the mail has sent or something like that. But I need some idea to implement that logic. I think it’s not possible to have UI for windows service. SO I thought of creating another windows application to show the pop up message and call this from the windows service when the mail has sent. This is only the idea and not sure is this correct approach. Please guide me.

谢谢.

推荐答案

windows 服务不应该有任何 GUI 没有限制.Windows 服务可以有 GUI.但如果有,它会出现在服务 0 中.在 Vista 之前的早期 Windows 版本中是可能的.让我们详细讨论一下.
     每当用户登录到 Windows 时,就会创建一个登录会话.每个会话都有一个会话 ID.所有 Windows 服务都将在会话 0 中运行.
    在会话 0 中,用户可以查看在那里运行的任何程序的图形元素并与之交互,包括由 Windows 服务在早期版本(如 Windows NT、2000、XP 和 Server 2003.
    后来出于安全考虑,微软隔离了Session 0.影响是服务无法显示其GUI.这是其中一种情况.
     考虑一下,服务尝试在会话 0 中创建用户界面 (UI),例如对话框.因为由于服务 0 的隔离,用户没有在会话 0 中运行,所以他或她永远不会看到 UI,因此无法提供服务正在寻找的输入.该服务似乎停止运行,因为它正在等待没有发生的用户响应.
    由于这种隔离,服务无法通过 Windows 消息与应用程序通信,反之亦然.我们使用 RPC、交互式服务检测服务 (ISDS) 和 IPC 来进行服务和应用程序之间的通信.

There is no restriction that windows service should not have any GUI. Windows services can have GUI. But if it has, it was shown up in Service 0. It was possible in earlier versions of Windows before Vista. Lets have a detailed discussion on it.
      A logon session is created whenever a user logs in to Windows. Each session has a Session ID. All the windows services will run in Session 0.
      In Session 0, a user can see and interact with the graphical elements of any program running there, including those created by Windows Services in earlier versions like Windows NT, 2000, XP and Server 2003.
       Later due to security concerns, Microsoft isolated the Session 0. And the impact is services cannot show their GUI. This is one of the case.
       Consider, A service attempts to create a user interface (UI), such as a dialog box, in Session 0. Because the user is not running in Session 0 due to the isolation of service 0, he or she never sees the UI and therefore cannot provide the input that the service is looking for. The service appears to stop functioning because it is waiting for a user response that does not occur.
      Due to this isolation, services cannot communicate with the applications through Windows message and vice versa. We use RPC, Interactive Services Detection Service (ISDS) and IPC for the communication between services and applications.

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

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