What are windows services? How are they differ from other .NET application?

空扰寡人 提交于 2019-12-10 23:10:04

问题


What are windows services? How are they different from other .NET application? Any references or examples are welcome which sight the differences


回答1:


Windows service is a Windows concept and generally does not really have anything to do with .NET per se other than that these could be written in .NET languages.

The main difference between a service and an ordinary windows app

  • Services always run (usually started when computer boots; depending on design, you can manually stop or start these)
  • Services have no UI (If you want to show UI from a service, you need to do it via a separate process) and mostly do not interact directly with users
  • Services run in a separate Windows session (mostly, session 0) and, therefore, are (most always) shared between all users of a computer
  • Services may offer recovery actions (what to do on first, second, and subsequent failures)
  • Services are a bit harder to write and especially to debug. Thus, if thinking of writing a service, please consider console app + scheduled task first windows service vs scheduled task



回答2:


Here's a good article about Windows Services:

Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. These features make services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer.

At the bottom of the article you have other links pointing to examples about how to create a Windows Service in .NET.




回答3:


Really, windows services are just a particular kind of program, which target the API defined in the System.ServiceProcess namespace. If you check out the reference page, there's some good documentation on creating a service.

Aside from that, you're just writing a regular old .Net program.




回答4:


In Windows NT operating systems, a Windows service is a computer program that operates in the background. Windows services can be configured to start when the operating system is started and run in the background as long as Windows is running. Alternatively, they can be started manually or by an event.



来源:https://stackoverflow.com/questions/9461619/what-are-windows-services-how-are-they-differ-from-other-net-application

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