长期运行的应用程序 [英] long term running application

查看:89
本文介绍了长期运行的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有GUI的应用程序,它必须在我用来使用Windows服务运行长期后台应用程序的界面的最顶层上可以长期运行,但是这次我有一个gui,我将gui和另一个是控制器,它控制ui屏幕的流程并执行一些后台操作,因此,如果有人对如何长期运行gui应用程序有任何想法,并且一旦系统在重新启动后运行,我就必须启动该应用程序. />
到现在为止,我还不知道如何长期运行该应用程序以及关机和启动以及Windows服务做了什么



请提供任何帮助,我还是有一个不错的主意,但是我现在不喜欢使用它.

I have an application with GUI that it must run for long term on the most top of the interface i used to use windows services to run long term background application but this time i have a gui with, i have i separate gui and another one is the controller that controls the flow of the ui screens and do some background operations, so if anyone had any idea on how to run gui application for long term and i have to launch the application once the system runs after reboot.

till now i have no idea on how to run the application for long term and shutdown and starting and what ever the windows service do



please any help is graceful i have another idea but i do not like to use it for now

推荐答案

据我了解,您称长期运行该应用程序会以人们登录和注销的身份执行,并在重新启动后开始运行.您可以使用Windows服务而不是UI应用程序来执行此操作. (毕竟,如果用户注销,则没有桌面作为UI父级;谁将与此类应用程序进行交互?)

因此,仅当有人登录时,您才需要启动此类UI.您可以响应系统事件而触发从服务中执行此类应用程序.要处理此类事件,您的Windows Service应用程序可以使用类Microsoft.Win32.SystemEvents.要处理用户登录/注销事件,您需要向某些或所有会话事件添加处理程序:SessionEndedSessionEndingSessionSwitch:
http://msdn.microsoft.com/en-us/library/microsoft.win32. systemevents.aspx [ ^ ].

我建议使此类UI应用程序成为Windows Service应用程序的瘦客户端,尽可能瘦-纯UI.所有应用程序逻辑,持久性等-最好驻留在Windows Service应用程序中. UI应用程序可以通过IPC与Windows Service通信,IPC可以基于Windows Service应用程序自托管的套接字,命名管道,经典远程处理或WCF.

—SA
As I understand, you call long-term run the application which keeps executing as people login and logout and starts running after reboot. You can do so with the Windows Service, not with the UI application. (After all, it the users logout, there is no a desktop to he a UI parent; and who would interact with such application?)

So, you will need to have such UI started only when someone login. You can trigger executing such application form your service, in response to system events. To handle such events, your Windows Service application can use the class Microsoft.Win32.SystemEvents. To handle user login/logout events, you need to add handlers to some or all of the session events: SessionEnded, SessionEnding or SessionSwitch:
http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.aspx[^].

I would advise to make such UI application a thin client of your Windows Service application, as thin as possible — pure UI. All application logic, persistence, etc. — should better reside in the Windows Service application. The UI application can communicate to your Windows Service via IPC, which can be based on sockets, named pipes, classical remoting or WCF self-hosted by the Windows Service application.

—SA


这篇关于长期运行的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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