[C # Windows Service] Getting started with "1,

Source: Internet
Author: User

[C # Windows Service] Getting started with "1,

[C # Windows Service] Getting started with "1"

 

 

Directory:

 

1.[C # Windows Service] Getting started with "1"

 

2.[C # Windows Service] INI configuration file 

 

I. tools:

VS2015 + NET Framework4.5.

 

Ii. Operations:

1. Create a windows Service Project:

 

 

2. Modify windows Services:

 

 

 

 

3Preview the windows service code structure:

 

4Windows Service generation and release:

 

 

 

 

 

 

 

 

Iii. Code:

1. Test code:

Using ClassLibrary1; using System. collections. generic; using System. componentModel; using System. data; using System. diagnostics; using System. linq; using System. serviceProcess; using System. text; using System. threading; using System. threading. tasks; namespace WindowsServiceTest {public partial class Service1: ServiceBase {public Service1 () {InitializeComponent ();} protected override void OnStart (string [] args) {Thread thread = new Thread (delegate () {try {for (int I = 0; I <1000; I ++) {LogHelp. writeLog ("Service Startup" + I) ;}} catch (Exception ex) {LogHelp. writeLog ("service startup failed" + ex) ;}}); thread. name = "thread Test 1"; thread. isBackground = true; thread. start () ;}protected override void OnStop (){}}}

  

 

2. bat file code

Install the Service Code: SC delete WindowsServiceTestsc create WindowsServiceTest start = auto binPath = D: \ www \ Debug \ WindowsServiceTest.exe SC description WindowsServiceTest "BY Eadily" pause uninstall service code: net stop WindowsServiceTestsc delete WindowsServiceTest

  

 

Iv. Summary:

 

 

 

 

Record every day, code every line of code

 

 

 

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.