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 ()