JFLarvoire / SysToolsLib

A library of Windows and Linux system management tools
Apache License 2.0
314 stars 93 forks source link

Clarify how to use PSService.ps1 #16

Closed PaulWalkerUK closed 6 years ago

PaulWalkerUK commented 6 years ago

Please can you confirm my understanding of how to implement PSService.ps1?

Am I right in thinking I put my "application code" within the TimerTick event handler?

If I want to change how frequently it runs, I just change the $period variable?

The only other things to change are the script name (becomes the service name) and the service display name and description?

JFLarvoire commented 6 years ago

If all you need is code that runs periodically, for example for monitoring something periodically, yes this is all what you have to do.

If you need something more reactive, for example to write a Web server in PowerShell, then you'll have to create worker threads that wait for network packets, and distribute tasks to other threads. All the bricks for doing it are there. But please don't ask me for more details. That's your problem, not mine :-)

PaulWalkerUK commented 6 years ago

That's great, thanks