StreamGuard.Core 1.0.1

dotnet add package StreamGuard.Core --version 1.0.1
                    
NuGet\Install-Package StreamGuard.Core -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StreamGuard.Core" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StreamGuard.Core" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="StreamGuard.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StreamGuard.Core --version 1.0.1
                    
#r "nuget: StreamGuard.Core, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StreamGuard.Core@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StreamGuard.Core&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=StreamGuard.Core&version=1.0.1
                    
Install as a Cake Tool

StreamGuard

A lightweight .NET library that prevents Windows sleep, display power-off and hibernation during long-running tasks such as streaming, monitoring or automation.

.NET Platform License


Features

✔ Prevent Windows sleep ✔ Prevent display power-off ✔ Optional hibernation control ✔ Automatic restore of original power settings ✔ Lightweight .NET library ✔ Works with Console, WPF or background services


Why StreamGuard?

Many users try to prevent Windows sleep using manual power settings or simple utilities.

StreamGuard provides a more reliable solution.

Compared to manual power settings

Manual configuration can easily be forgotten or changed by the system.

StreamGuard:

  • automatically applies the required power policies
  • keeps the system awake while running
  • restores the original settings when finished

Compared to simple "keep awake" tools

Many tools only call SetThreadExecutionState.

StreamGuard also manages:

  • display timeout policy
  • sleep timeout policy
  • optional hibernation control

Designed for developers

StreamGuard is implemented as a reusable .NET library that can be integrated into:

  • Console applications
  • WPF applications
  • monitoring tools
  • background services
  • automation systems

Quick Start

using StreamGuard.Core;

var options = new StreamGuardOptions();

using var service = new StreamGuardService(options);

service.Log += Console.WriteLine;

await service.StartAsync();

// long running work here
await Task.Delay(TimeSpan.FromHours(1));

await service.StopAsync();

Architecture

StreamGuard is built around a small service layer that manages Windows power APIs.

+-----------------------+
| Console / WPF / Host  |
+-----------+-----------+
            |
            v
+-----------------------+
|  StreamGuardService   |
+-----------+-----------+
            |
      +-----+-----+
      |           |
      v           v
+-----------+ +------------------+
| Options   | | Snapshot         |
+-----------+ +------------------+
            |
            v
+-------------------------------+
| Internal Windows integration  |
+---------------+---------------+
                |
         +------+------+
         |             |
         v             v
   PowerPolicyApi   HibernateFacade
         |             |
         v             v
    powrprof.dll   powercfg.exe

Service Lifecycle

Stopped
   |
   v
Starting
   |
   v
Capture snapshot
   |
   v
Apply policy
   |
   v
Running
   |
   v
Maintain loop
   |
   v
Stopping
   |
   v
Restore snapshot
   |
   v
Stopped

The service also exposes events:

service.StateChanged += s => Console.WriteLine($"State: {s}");
service.Log += Console.WriteLine;

Configuration

Behavior can be customized using StreamGuardOptions.

Example:

var options = new StreamGuardOptions
{
    MaintainInterval = TimeSpan.FromSeconds(30),

    PreventDisplayOff = true,
    PreventSleep = true,
    DisableHibernate = true,

    DisplayTimeoutAcSeconds = 0,
    DisplayTimeoutDcSeconds = 0,

    SleepTimeoutAcSeconds = 0,
    SleepTimeoutDcSeconds = 0
};

A value of 0 usually means never.


Project Structure

StreamGuard
 ├─ StreamGuard.Core
 ├─ StreamGuard.Console
 ├─ StreamGuard.Wpf

StreamGuard.Core contains the reusable library.

The Console and WPF projects are simple demo hosts.


Windows Requirements

StreamGuard relies on Windows power APIs.

Recommended environment:

  • Windows 10 or Windows 11
  • .NET 6 or later

Some power policy operations may require administrator privileges.


License

MIT License

Product Compatible and additional computed target framework versions.
.NET net9.0-windows7.0 is compatible.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 84 3/7/2026
1.0.0 79 3/6/2026