Enter any website URL to analyze its complete technology stack

Executive Summary for www.mantratocode.com

2000 Response Time (ms)
200 HTTP Status
21 Scripts
26 Images
21 Links
HTTP/1.1 Protocol

SEO & Content Analysis

Basic Information
Page Title
A Programming Blog -
Meta Description
Not detected
HTML Language
en-US
Robots.txt Present
Sitemap Present
total_urls: 6
SEO Meta Tags
content-type: text/html; charset=UTF-8
Page Content

A Programming Blog -

There are various ways to create a windows service. We can create a window service project from a standard visual studio template, or we can create a console application and can extend a ServiceBase class which will convert our application to windows service. In all these above methods we have to write a lot of manual code to configure our application so that it will function properly, besides our business logic.Wouldn’t it be nice to get rid of all these config related stuff and to just focus on actual service functionality, without knowing how ServiceBase works.Yes, that is absolutely possible. There is an open source Windows Service Framework TopShelf developed for .net platform.TopShelf makes task of creating a window service very easy. More documentation about topshelf can be found at documentation.Lets us try our hand at coding a window service using TopShelf. We will also deploy it with a single command from command prompt.Create a console application named as WinServTopShelf.We will have to add a reference of Topshelf.dll in our console application. There are multiple ways to add the reference. You can use NuGet Package Manager or binaries can be directly downloaded from GitHub.I am going with a second method. Download a zip file and unzip it. Include a reference of Topshelf.dll in WinServTopShelf console application project. Now, add a new class named as WinTopShelf in this application. We will add two methods in this class which are Start() and Stop() as shown below public void Start() { } public void Stop() { } Now Lets start writing our service logic. public class WinTopShelf { Timer timer; public WinTopShelf() { timer = new Timer(); } public void Start() { } public void Stop() { } } In above code I have initialized a timer class member in constructor. I am going to create a timer based service, to which a dedicated task will be assigned. This task will be executed after elapsed time ticks which we will of course configure in the code.Now let us write a task which would be assigned to ElapsedEventHandler event of timer.Our task will create a file at C:\TopShelf\task.txt location and will append the text in this file. public class WinTopShelf { Timer timer; public WinTopShelf() { timer = new Timer(); } private void DoWork(object sender, ElapsedEventArgs e) { using (var writer = new StreamWriter(@"C:\TopShelf\task.txt", true)) { writer.WriteLine(DateTime.Now + " Topshelf has made windows service development very easy"); } } public void Start() { timer.Interval = 60000; timer.Elapsed += new ElapsedEventHandler(DoWork); timer.Start(); } public void Stop() { timer.Stop(); } } Above code is self explanatory. Now I will show you how to integrate Topshelf’s capabilities to convert our this simple console application to a window service.While creating a project, a default class Program is added, in which Main method resides.This Main method is the entry point of the application. To start with TopShelf, we have to use Topshelf namespace.TopShelf provides HostFactory class to facilitate different tasks. In Main() method we just have to write a logic using HostFactory.Run() method, in which we will write a very simple and readable code which is analogous to the implementation of ServiceBase class. static void Main(string[] args) { HostFactory.Run(r => { r.Service<WinTopShelf> (service => { service.ConstructUsing(instance => new WinTopShelf()); service.WhenStarted(instance => instance.Start()); service.WhenStopped(instance => instance.Stop()); }); }); } In above code, r.Service specifies that WinTopShelf should be used as the service class.service.ConstructUsing(instance => new WinTopShelf()) statement specifies which constructor to be used to create an instance of WinTopShelf class.service.WhenStarted(instance => instance.Start()) statement specifies method to be executed when service starts.service.WhenStopped(instance => instance.Stop()) statement specifies method to be executed when service stops.I will add some more essential code as shown below: static void Main(string[] args) { HostFactory.Run(r => { r.Service<WinTopShelf> (service => { service.ConstructUsing(instance => new WinTopShelf()); service.WhenStarted(instance => instance.Start()); service.WhenStopped(instance => instance.Stop()); }); r.RunAsLocalService(); r.SetDisplayName("Topshelf facilitated service"); r.SetDescription("This service has been created using a TopShelf open source framework for creating a windows serviecs."); } ); } r.RunAsLocalService() specifies that how to run the service when it gets installed. I chose to run the service as a local service. Other alternatives are RunAsLocalSystem(), RunAsNetworkService() and RunAsPrompt().SetDisplayName and SetDescription are used to set the display name and description of the service which can be seen in the service control manager console.So our service is now ready to compile and install. Compile our project WinServTopShelf.Let us install this service. Run a command prompt as an administrator and navigate to the directory where you have to place the WinServTopShelf.exe and other compiled assemblies.Execute WinServTopShelf.exe install command. Done!!!!!! Our service has been installed.Now to start the service you need to open the service control manager and search for service name which we have configured as Topshelf facilitated service.You can start the service and it will run smoothly. To see the output open a file C:\TopShelf\task.txt on your machine and see the result. To summarize this we can say that it is very easy and quick way to create a window service using TopShelf and you should have a knowledge of lambda expression and syntax to use it.A complete code sample can be downloaded from GitHub. This code sample is created using Visual Studio 2015.Enjoy Coding!!!!Do not forget to share this post if you liked the content.Buy books from Amazon;

Network & Infrastructure

DNS & Hosting
IP Address
111.118.215.222
Reverse DNS
cp-in-9.webhostbox.net
SSL/TLS Certificate
Issuer
Protocol
Expires In 0 days

Technology Stack

Content Management Systems
WordPress
JavaScript Frameworks
Ember jQuery
Server Technologies
Generator: WordPress 6.9 PHP (inferred from WordPress)

Services & Integrations

Analytics & Tracking
Google Analytics GA4 Google Tag Manager
Advertising & Marketing
Amazon Ads
E-commerce Platforms
Magento PrestaShop
Email Marketing
Mailchimp
A/B Testing
Google Optimize

CDN & Media Providers

Web Fonts
Font Awesome Google Fonts

Dynamic Analysis & Security

Dynamic JavaScript Analysis
Angular (Data Attributes) Bootstrap (CSS Classes) ES6+ JavaScript Features Font Awesome (CDN Detection) jQuery (CDN Detection) jQuery (script Resource) REST/GraphQL API (Pattern Detection) Web Server: Apache
Server Headers
nginx/1.23.4

Resource Analysis

External Resource Hosts
analytics.shareaholic.com
c.amazon-adsystem.com
cdn-images.mailchimp.com
cdn.openshareweb.com
cdn.shareaholic.net
fonts.googleapis.com
gmpg.org
media.licdn.com
partner.shareaholic.com
recs.shareaholic.com
www.mantratocode.com
www.shareaholic.net
UI Frameworks & Libraries
Angular Material (Class Names) Bootstrap (Class Names) D3.js Font Awesome Ionic (Class Names) Slate Vuetify (Class Names)

Social Media Integrations

Analysis Complete

Analyzed www.mantratocode.com with 6 technologies detected across 10 categories

Analysis completed in 2000 ms • 2026-03-23 11:01:20 UTC