C # implements the installation and deletion of Windows services

Source: Internet
Author: User

Today, for everyone to organize an article on C # Implementation of Windows service production and installation and delete articles, hope to help learn C # students to further improve the level of learning.

Run Visual Studio.NET to establish a C # Windows service project.

Main program code:

The following are the referenced contents:

The following is a reference fragment:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
Namespace Careeye
... {
public class CareEye:System.ServiceProcess.ServiceBase
... {
Private Thread mainthread;
/**////
///the required designer variables.
///
Private System.ComponentModel.Container components = null;
public careeye ()
... {
//This call is required for the Windows.Forms Component Designer.
InitializeComponent ();
//TODO: Add any initialization
Mainthread = new Thread (new ThreadStart (ThreadFunc) after the initcomponent call);
mainthread.priority = Threadpriority.lowest;
}
//process's main entry point
static void Main ()
... {
//system.serviceprocess.servicebase[] servicestorun;
//Multiple User services can be run in the same process. To add a
//another service to this process, change the downlink
//To create another service object. For example,
//
//ServicesToRun = new system.serviceprocess.servicebase[] {new Careeye (), New MySecondUserService ()};
//
//servicestorun = new system.serviceprocess.servicebase[] {new Careeye ()};
System.ServiceProcess.ServiceBase.Run (New Careeye ());
}
/**////
///Designer supports the desired method-do not use the Code Editor
///Modify the contents of this method.
///
private void InitializeComponent ()

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.