Skip to content

Commit b2efc2c

Browse files
committed
Release StreamGuard.Core 1.0.1
1 parent de6b958 commit b2efc2c

4 files changed

Lines changed: 180 additions & 52 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: StreamGuard Core CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build-core:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v5
19+
with:
20+
dotnet-version: '9.0.x'
21+
22+
- name: Restore Core
23+
run: dotnet restore StreamGuard.Core/StreamGuard.Core.csproj
24+
25+
- name: Build Core
26+
run: dotnet build StreamGuard.Core/StreamGuard.Core.csproj --configuration Release --no-restore
27+
28+
- name: Pack Core
29+
run: dotnet pack StreamGuard.Core/StreamGuard.Core.csproj --configuration Release --no-build -o ./artifacts
30+
31+
- name: Upload NuGet package
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: StreamGuard.Core-nupkg
35+
path: artifacts/*.nupkg

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ obj/
44
*.user
55
*.suo
66
*.cache
7-
*.pdb
7+
*.pdb
8+
.gitignore

README.md

Lines changed: 132 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
11
# StreamGuard
22

3-
StreamGuard is a small Windows utility library that helps prevent the system from entering sleep mode, turning off the display, or entering hibernation during long-running tasks such as streaming.
3+
A lightweight .NET library that prevents Windows sleep, display power-off and hibernation during long-running tasks such as streaming, monitoring or automation.
44

5-
The project provides a reusable .NET library (`StreamGuard.Core`) and optional demo applications (Console and WPF).
5+
![.NET](https://img.shields.io/badge/.NET-6%2B-blue)
6+
![Platform](https://img.shields.io/badge/platform-Windows-lightgrey)
7+
![License](https://img.shields.io/badge/license-MIT-green)
68

79
---
810

911
# Features
1012

11-
StreamGuard can:
13+
✔ Prevent Windows sleep
14+
✔ Prevent display power-off
15+
✔ Optional hibernation control
16+
✔ Automatic restore of original power settings
17+
✔ Lightweight .NET library
18+
✔ Works with Console, WPF or background services
1219

13-
* Prevent the display from turning off
14-
* Prevent the system from entering sleep mode
15-
* Disable hibernation while running
16-
* Maintain the keep-awake state using a background watchdog
17-
* Restore the original power settings when stopped
20+
---
1821

19-
The library works by combining:
22+
# Why StreamGuard?
2023

21-
* `SetThreadExecutionState` (real-time keep awake)
22-
* Windows Power Policy APIs (`powrprof.dll`)
23-
* `powercfg.exe` where required
24+
Many users try to prevent Windows sleep using manual power settings or simple utilities.
2425

25-
---
26+
StreamGuard provides a more reliable solution.
2627

27-
# Project Structure
28+
### Compared to manual power settings
2829

29-
```
30-
StreamGuard
31-
├─ StreamGuard.Core # Main reusable library
32-
├─ StreamGuard.Console # Example console host
33-
├─ StreamGuard.Wpf # Example WPF UI
34-
```
30+
Manual configuration can easily be forgotten or changed by the system.
3531

36-
`StreamGuard.Core` contains the complete implementation and is the only required component.
32+
StreamGuard:
3733

38-
---
34+
* automatically applies the required power policies
35+
* keeps the system awake while running
36+
* restores the original settings when finished
37+
38+
### Compared to simple "keep awake" tools
39+
40+
Many tools only call `SetThreadExecutionState`.
41+
42+
StreamGuard also manages:
43+
44+
* display timeout policy
45+
* sleep timeout policy
46+
* optional hibernation control
3947

40-
# Installation
48+
### Designed for developers
4149

42-
Currently the library can be referenced directly from source.
50+
StreamGuard is implemented as a reusable .NET library that can be integrated into:
4351

44-
Later it may be distributed as a NuGet package.
52+
* Console applications
53+
* WPF applications
54+
* monitoring tools
55+
* background services
56+
* automation systems
4557

4658
---
4759

48-
# Basic Usage
60+
# Quick Start
4961

5062
```csharp
5163
using StreamGuard.Core;
@@ -58,17 +70,93 @@ service.Log += Console.WriteLine;
5870

5971
await service.StartAsync();
6072

61-
// Long running work here
62-
await Task.Delay(TimeSpan.FromHours(2));
73+
// long running work here
74+
await Task.Delay(TimeSpan.FromHours(1));
6375

6476
await service.StopAsync();
6577
```
6678

6779
---
6880

81+
# Architecture
82+
83+
StreamGuard is built around a small service layer that manages Windows power APIs.
84+
85+
```
86+
+-----------------------+
87+
| Console / WPF / Host |
88+
+-----------+-----------+
89+
|
90+
v
91+
+-----------------------+
92+
| StreamGuardService |
93+
+-----------+-----------+
94+
|
95+
+-----+-----+
96+
| |
97+
v v
98+
+-----------+ +------------------+
99+
| Options | | Snapshot |
100+
+-----------+ +------------------+
101+
|
102+
v
103+
+-------------------------------+
104+
| Internal Windows integration |
105+
+---------------+---------------+
106+
|
107+
+------+------+
108+
| |
109+
v v
110+
PowerPolicyApi HibernateFacade
111+
| |
112+
v v
113+
powrprof.dll powercfg.exe
114+
```
115+
116+
---
117+
118+
# Service Lifecycle
119+
120+
```
121+
Stopped
122+
|
123+
v
124+
Starting
125+
|
126+
v
127+
Capture snapshot
128+
|
129+
v
130+
Apply policy
131+
|
132+
v
133+
Running
134+
|
135+
v
136+
Maintain loop
137+
|
138+
v
139+
Stopping
140+
|
141+
v
142+
Restore snapshot
143+
|
144+
v
145+
Stopped
146+
```
147+
148+
The service also exposes events:
149+
150+
```csharp
151+
service.StateChanged += s => Console.WriteLine($"State: {s}");
152+
service.Log += Console.WriteLine;
153+
```
154+
155+
---
156+
69157
# Configuration
70158

71-
`StreamGuardOptions` allows control over which policies are enforced.
159+
Behavior can be customized using `StreamGuardOptions`.
72160

73161
Example:
74162

@@ -89,38 +177,38 @@ var options = new StreamGuardOptions
89177
};
90178
```
91179

92-
`0` usually means **never**.
180+
A value of `0` usually means **never**.
93181

94182
---
95183

96-
# Service Lifecycle
97-
98-
The service exposes the following states:
184+
# Project Structure
99185

100186
```
101-
Stopped → Starting → Running → Stopping
102-
103-
Faulted
187+
StreamGuard
188+
├─ StreamGuard.Core
189+
├─ StreamGuard.Console
190+
├─ StreamGuard.Wpf
104191
```
105192

106-
You can subscribe to events:
193+
`StreamGuard.Core` contains the reusable library.
107194

108-
```csharp
109-
service.StateChanged += s => Console.WriteLine($"State: {s}");
110-
service.Log += Console.WriteLine;
111-
```
195+
The Console and WPF projects are simple demo hosts.
112196

113197
---
114198

115199
# Windows Requirements
116200

117201
StreamGuard relies on Windows power APIs.
118202

119-
* Windows 10 / 11 recommended
120-
* Some power policy changes may require administrator privileges
203+
Recommended environment:
204+
205+
* Windows 10 or Windows 11
206+
* .NET 6 or later
207+
208+
Some power policy operations may require administrator privileges.
121209

122210
---
123211

124212
# License
125213

126-
MIT (recommended)
214+
MIT License

StreamGuard.Core/StreamGuard.Core.csproj

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66

7-
<!-- GitHub/NuGet-ready metadata -->
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
<WarningsAsErrors>CS1591</WarningsAsErrors>
9+
10+
<!-- GitHub / NuGet metadata -->
811
<PackageId>StreamGuard.Core</PackageId>
12+
<Version>1.0.1</Version>
913
<Authors>Ferenc Biro</Authors>
10-
<!-- <RepositoryUrl>
11-
https://github.com/<your-user>/StreamGuard</RepositoryUrl> -->
14+
<Description>Prevent Windows sleep, display power-off and hibernation during long-running tasks.</Description>
15+
<RepositoryUrl>https://github.com/pmonitor0/StreamGuard</RepositoryUrl>
1216
<PackageLicenseExpression>MIT</PackageLicenseExpression>
17+
<PackageTags>windows;sleep;power-management;streaming;keep-awake</PackageTags>
1318
<PackageReadmeFile>README.md</PackageReadmeFile>
1419
</PropertyGroup>
1520

16-
<PropertyGroup>
17-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
18-
<WarningsAsErrors>CS1591</WarningsAsErrors>
19-
</PropertyGroup>
21+
<ItemGroup>
22+
<None Include="..\README.md" Pack="true" PackagePath="\" Link="README.md" />
23+
</ItemGroup>
2024
</Project>

0 commit comments

Comments
 (0)