Intro to Windows Services in C# - How to create, install, and use a service using Topshelf

preview_player
Показать описание

Services in Windows are really powerful tools for automation, but they are often overlooked. These small applications run constantly in the background and can be used for a number of tasks from the simple to the complex. In this video, we are going to look at how to create a service, how to run it and debug it, and how to install it.

0:00 - Intro
0:51 - Creating Console Demo Application
1:45 - What is a Windows Service
3:30 - Visual Studio service app template vs console app
5:00 - Topshelf NuGet reference
5:58 - Service app code design
20:49 - Running the Service App
22:07 - Installing and uninstalling the Service
26:44 - Recap
27:11 - Ideas for a Service Applications
30:10 - Summary and concluding remarks

Thanks to Ralfs HBK for the chapter breakdown
Рекомендации по теме
Комментарии
Автор

I don't know if you'll ever read this, I started learning C# about 2 weeks ago. I needed a new hobby for the quarantine and I figured that this one will do. You're honestly one of the most gifted people in passive knowledge I've ever encountered in my life, thank you for all the work you're putting in for us common people to learn. I can only wish you to never stop doing this for as long as you're enjoying this. Thank you very much.

Stolen_Bus
Автор

Thanks Tim, this is exactly what I needed. My buddy at work needed something to scan a directory for files, process the file data and generate an xml document for each file. It allows 2 systems to communicate that otherwise couldn’t, saving a project. Scheduled a Teams meeting to get the details of what he needed… 10 mins in I pulled up this video and 45 mins later we had it working! It was my first service too. Your content has made me a lot of money over the years! 150% increase in pay over the last 5 years at a large multinational company, the biggest contributing factor being the ability rapidly to solve little issues like this. It even got me an opportunities to go to Microsoft’s executive briefing center in Redmond. Never would have thought I would have the opportunities 5 years ago. I’ve had the all access pass to your paid content for a few years now and it’s worth every penny. The new Blazor course is great. I turned another buddy at work on to your content and he purchased a course too. Keep up the great work Tim!

Nathan_W
Автор

if I had discovered this channel earlier, I would have saved myself a lot of headaches.

germang.
Автор

I'm a junior c# full stack developer and I have to say Sir, you are a great help, not only make it easy to understand with step by step tutorial and also with a very clear and easy understand explanation. Thank you.

jianhuichua
Автор

WOW! I've been avoiding using services for over 10 years cause of the messiness of troubleshooting while developing. Today while watching your video, I learned how to, and proceeded to convert a simple console application to a service. Thanks a million!

rupertopasillas
Автор

Wow, I'd heard about TopShelf, but never really looked into it, this makes debugging services so much easier - and looks easy to convert existing services to use Topshelf - Thanks Tim!

harag
Автор

Definitely deserves a like. However, I recently had to implement a service for work and I got the 1053 error when I started it. What it said was
"The service did not respond to the start or control request in a timely fashion"

Instead of writing the following start method as mentioned in your video
public void start()
{
//instantiate a bunch of objects and running through the constructors
}

I use start to call async codes as the following
public void start()
{
_callStartTasksAsync();
}
private async Task _callStartTasksAsync()
{
await Task.Run(()=>{ //instantiate a bunch of objects and running through the constructors } )
}

This allowed the service to get through the start method ASAP and avoided the error

chunkyazian
Автор

Have been waiting for this topic for a REALLY long time!!! thank you a LOT TIM!!! you are taking this channel to the next level... not kidding here!

rodrigo
Автор

What an absolutely SUPERB video - so well explained and I wrote a Windows Service in less than 3 minutes after watching this start to finish. Absolutely brilliant. Thank you!

jonnywilson
Автор

Love the detail and simplicity of this video. Excellent.

dronefootage
Автор

Messing around with NSSM utility to run existing applications as a service, I decided to look for way to write my own service from scratch for more flexibility and to come up with a rock-solid approach that also allows easy debugging and testing. Found your "Windows Services in C#" tutorial -> bullseye! Thanks for your great work.

marcjacquinot
Автор

I made a small service to routinely clean up my downloads folder like you suggested. Works great! You are inspiring me to "play with" C# more than I did in the past with all these great tutorials!

bryandpalmer
Автор

This video “inspired me” to actually implement the “download folder keeper” as a service, and I’m almost done, if any one is interested I will be uploading probably tomorrow the source code to github, I used what Tim tough in a video about directories but I also implemented a way to find the “default” download folder for your computer. Also used the “app.conf” as Tim also did as a challenge a few weeks ago.

Thanks once again Tim... you had built a great community to share knowledge and learn!

rodrigo
Автор

Thanks Tim! This couldn't have come at a better time. I just started to write a service on Friday and now I'm going to do it this way. Love your videos; they are so easy to understand.

debkelly
Автор

Lot of thanks to you friend. Its really helpful for everyone to easy to understand and has lot of value. Thank you again and again. Keep up good work

bimalsubasinghe
Автор

Tim - thanks - I just finished your c# mastercourse (which was great!) and am embarking on my own projects to build a portfolio. I have a desktop scanner and a printer, and I'm going to create a service that watches the folder for newly scanned pdfs and then prints them - essentially a photocopier. Thanks to your helpful videos, I think I can pull this off.

dhhqqts
Автор

Thanks Tim, I am so glad that I came across your channel!

llopez
Автор

You are a life saver. This was exactly what I was looking for. Perfectly explained and super easy to follow.

alexstahl
Автор

Crystal clear explanation. Exactly what I was looking for!

densed
Автор

The best lecture ever. I was Wondering on how to sync SQLite database files to the main server and I thought of checking how services work and here you explained it so clearly Thank you

lawre_