Simplest service : Service : Windows C# Examples


C# Examples » Windows » Service »

 

Simplest service









    
using  System;
using  System.Collections;
using  System.ComponentModel;
using  System.Data;
using  System.Diagnostics;
using  System.ServiceProcess;

public  class  Service1  :  System.ServiceProcess.ServiceBase
{
    public  Service1()
    {
        this.ServiceName  =  "MyRealService";
    }

    static  void  Main()
    {
        System.ServiceProcess.ServiceBase[]  ServicesToRun;

        ServicesToRun  =  new  System.ServiceProcess.ServiceBase[]  {  new  Service1()  };

        System.ServiceProcess.ServiceBase.Run(ServicesToRun);
    }
    protected  override  void  OnStart(string[]  args)
    {
        int  x  =  1;
    }

    protected  override  void  OnStop()
    {

    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Windows
» Service