Create A Windows Service In Asp.Net C#

Create A Windows Service In Asp.Net C#

In this post, how to create windows servises in asp.net using c#, you can start, stop, and pause a service from here by right click on the service. Windows service is a computer program that runs in the background to execute some tasks. If you open your Task Manager and click on the Services tab, you will see hundreds of services running on your machine. You can also see the statuses of these services. Some examples of Windows services are  check emails, print documents, SQL Server agent, auto-update of Windows, file and folder scanning and indexing and so on.  Some services are running, some have paused, and some have stopped.

 

Create the project and set the values that are required for the service to function correctly.

From the Visual Studio File menu, select New > Project (or press Ctrl+Shift+N) to open the New Project window.

Navigate to and select the Windows Service (.NET Framework) project template. To find it, then select Windows Desktop. Or, enter Windows Service in the search box on the upper right and press Enter.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace DMCServices
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
        }

        protected override void OnStop()
        {
        }
    }
}

2020-04-01