Use. NET to create a Windows service

Source: Internet
Author: User
We will study how to create an application as a Windows service. The content includes what is a Windows service and how to create, install, and debug them. The System. ServiceProcess. ServiceBase namespace class is used.
What is a Windows service?
Windows service applications are applications that require long-term running. They are especially suitable for server environments. It does not have a user interface and does not produce any visual output. Any user message is written into the Windows event log. When the computer starts, the service automatically starts running. They do not run only when users log on. They can run in any user environment including the system. Through the service control manager, Windows services are controllable and can be terminated, paused, and started as needed.
Windows Services, formerly NT services, are introduced as part of the Windows NT operating system. They are not in Windows 9x or Windows Me. You need to use an NT-level operating system to run Windows services, such as Windows NT, Windows 2000 Professional, or Windows 2000 Server. For example, products in the form of Windows services include Microsoft Exchange and SQL Server, and Windows Time services such as computer clock settings.
Create a Windows service
The service we are about to create does nothing except demonstration. When the service is started, an entry is registered to a database to indicate that the service has been started. During service running, it regularly creates a database project record at a specified interval. When the service is stopped, the last database record is created. This service automatically registers with the Windows application log the records when it is successfully started or stopped.
Visual Studio. NET makes creating a Windows service quite simple. The following describes how to start the demo service program.
1. Create a project
2. Select a Windows service from the list of available Project templates
3. The designer opens in design mode.
4. Drag a Timer object from the component table in the toolbox to the design surface (note: make sure that Timer is used from the component list rather than from the Windows form list)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.