fun with windows services
TRANSCRIPT
![Page 1: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/1.jpg)
Fun with Windows Services
Michael Melusky – Tuesday November 18, 2014 (central penn .net)https://twitter.com/mrjavascripthttps://github.com/mrjavascript
![Page 2: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/2.jpg)
What is a Windows Service?
▪ A long running executable application that runs in its own Windows Session
▪ Can be started automatically upon Windows restart, can be paused and stopped
▪ No user interface is shown
![Page 3: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/3.jpg)
When to use Windows Services?
▪ Your program accepts incoming requests and connections (e.g. mail server, FTP server, et al.)
▪ If you need to do processing without an active user logged in
▪ Monitoring queues, file systems
![Page 4: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/4.jpg)
Managing Windows Services:
▪ In Windows 8.1, hit WIN key and type “services.msc”
▪ In Windows 7/XP, Run -> “services.msc”
![Page 5: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/5.jpg)
Managing Windows Services:
0
1
2
3
4
5
6
Category 1 Category 2 Category 3 Category 4
Chart Title
Series 1 Series 2 Series 3
![Page 6: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/6.jpg)
Windows Service Details
▪ Manage Startup Type
▪ Manage Service Status
▪ Manage Description
▪ Manage Security
![Page 7: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/7.jpg)
Goal of Windows Service Development?
![Page 8: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/8.jpg)
Alternatives to Windows Services:
▪ Windows Task Scheduler:– Ideal for nightly FTP retrieval
– Hourly backup
– Weekly Defrag
▪ Example (“Hello World”)
![Page 9: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/9.jpg)
Building Services with Visual Studio
▪ Can be built using the “Windows Service” project type in Visual Studio
▪ Built with either C# or VB.NET
▪ Example (“File Creator”)
![Page 10: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/10.jpg)
Topshelf
▪ http://topshelf-project.com/
▪ Easier approach for developing Windows Services
▪ Can convert a Windows Console application into a Service (easy for debugging!)
▪ NUGET:– PM> Install-Package Topshelf
▪ Example (“File Creator Redux”)
![Page 11: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/11.jpg)
Quartz.NET
▪ http://www.quartz-scheduler.net/
▪ Enterprise Job Scheduler ported from the famous Java framework– Jobs implement the IJob interface
– Jobs can be scheduled using Triggers
– Jobs and triggers can be stored in a data store (e.g. relational database)
▪ NUGET:– PM> Install-Package Quartz
![Page 12: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/12.jpg)
log4net
▪ http://logging.apache.org/log4net/
▪ Enterprise logging framework built off of the famous Java framework log4j
▪ NUGET– PM> Install-Package log4net
![Page 13: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/13.jpg)
Example #1
▪ Automated Backup
![Page 14: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/14.jpg)
Example #2
▪ Event Viewer
![Page 15: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/15.jpg)
Example #3
▪ Automated SMS Resource Reminder
![Page 16: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/16.jpg)
Example #4
▪ Fun with OneNote
![Page 17: Fun with windows services](https://reader030.vdocuments.us/reader030/viewer/2022032617/55aa96781a28ab124b8b482e/html5/thumbnails/17.jpg)
Example #5
▪ SQL Server Job Store