showing a popup form a windows service

ε祈祈猫儿з 提交于 2019-12-11 02:49:39

问题


Im looking for some advice on an application im creating using a windows service. Basically we have some timesheet software and i need to create a windows service that will poll a db to see if they have completed last weeks timesheet. If they havent completed it i want the application to popup a message stating that it is incomplete and that they should go and complete it.

Ive created a simple service from a tutorial i found and got it to install and run fine. I now need to think about the form side that popups up. Thing is im not sure its a good idea to do this from a service. Can anyone give me a steer on the best way to develop this application using a windows service.


回答1:


as mentioned earlier you may not create userinterfaces from within Services. In order to achieve this. you have to build another application. you can use Windows Forms or WPF for building the NotificationArea inteagration application.

I would use WCF with net tcp binding to communicate between both applications.




回答2:


Well as you aslmost said your self. This is not well suited for a windows service since there is nothing going on when a user is not logged in. If on the other hand you were also sending mails AND showing pop up a duel approach would be ideel.

I recommend scrapping the service and only use your form.




回答3:


You could develop ANOTHER WinForms application that reads from a Database (for example) every X seconds

Your Windows Service will write to the Database indicating whether the job is done or not.

once your Winforms application (that can sit in the system tray for example) reads from the database and sees the job is not done - make it pop up and alert the user.

Just a thought!



来源:https://stackoverflow.com/questions/8788325/showing-a-popup-form-a-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!