Nofity User some message from a windows service

倾然丶 夕夏残阳落幕 提交于 2019-12-24 14:54:19

问题


I have created a windows service which gets soem info from database and I want to notify user based on the info retreived from the DB. How can I notify user from a windows service using system tray notification? Can you please show me some sample (using IPC mechanism) to get the return value of a method used in a windows service in a system tray notification? Thanks in advance.


回答1:


There are several options such as these:

  1. Sockets: (Not too difficult to write, has firewall problems) You can find samples for it almost everywhere.
  2. External WinForm: (The easiest method, has security problems and might blocked by some antivirus apps) Just create a winForm with the ability to go into the windows notification area and then tell the service to run its exe file.
  3. Named Pipes: (Probably the most difficult, but it's the recommended solution) Here is a Code Project sample.
  4. Other tricks like: Create a hidden winform project (ShowInTask=false) and put it in StartUp. provide it with a FileSystemWatcher object and make it watch for a certain file which the service creates or deletes it to signal the winform.


来源:https://stackoverflow.com/questions/9077709/nofity-user-some-message-from-a-windows-service

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