C # compile the S service and deploy and install it

Source: Internet
Author: User

Using System;
Using System. Collections;
Using System. ComponentModel;
Using System. Data;
Using System. Diagnostics;
Using System. ServiceProcess;
Using System. IO;
Using System. Runtime. InteropServices;

Namespace FileMonitorService
{
Public class Service1: System. ServiceProcess. ServiceBase
{
/// <Summary>
/// Required designer variables.
/// </Summary>
Private System. ComponentModel. Container components = null;
Private bool servicePaused;
Private System. Diagnostics. PerformanceCounter fileChangeCounter;
Private System. Diagnostics. PerformanceCounter fileDeleteCounter;
Private System. Diagnostics. PerformanceCounter fileRenameCounter;
Private System. Diagnostics. PerformanceCounter fileCreateCounter;

Public Service1 ()
{
// This call is required by the Windows. Forms component designer.
InitializeComponent ();

// TODO: add any initialization after the InitComponent call
}

// Master entry point of the process
Static void Main ()
{
System. ServiceProcess. ServiceBase [] ServicesToRun;

// Multiple user services can be run in the same process. To
// Add another service to this process. Change the next line.
// Create another service object. For example,
//
// ServicesToRun = New System. ServiceProcess. ServiceBase [] {new Service1 (), new MySecondUserService ()};
//
ServicesToRun = new System. ServiceProcess. ServiceBase [] {new Service1 ()};

System. ServiceProcess. ServiceBase. Run (ServicesToRun );
}

/// <Summary>
/// The designer supports the required methods-do not use the code editor
/// Modify the content of this method.
/// </Summary>
Private void InitializeComponent ()
{

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.