Create installation debugging for Windows service

Source: Internet
Author: User

Creation of 1.windows Service

vs2012 Add Project Windows service

2. Main code

protected override void OnStart (string[] args) {System.Timers.Timer timer1 = new System.Timers.Timer (             ); Timer1. Interval = 3000;//interval time timer1. Elapsed + = new System.Timers.ElapsedEventHandler (stuadd);//The handler timer1 that is executed during the interval. AutoReset = true;//The System.Timers.Timer.Elapsed event is raised at the end of each interval, if only the first throw is set to false timer1.         Enabled = true; }

protected override void OnStop () {File.appendalltext (@ "D:\ServiceLog.log", String.         Format ("Stop time: {0}\r\n", DateTime.Now.ToString ())); }

3. Installation

CMD C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe The detailed address of the service you created \ your service. exe

4. Commissioning

Want to debug first your service has to be installed successfully

Start your service now in the service

1, Control Panel "management tool" service "Find your service right click" Start

In the VS tool "add" find your service add up "click OK

Create installation debugging for Windows service

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.