Oakrey.Applications.Performance 7.0.1

dotnet add package Oakrey.Applications.Performance --version 7.0.1
                    
NuGet\Install-Package Oakrey.Applications.Performance -Version 7.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="Oakrey.Applications.Performance" Version="7.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.Performance" Version="7.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Performance" />
                    
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 Oakrey.Applications.Performance --version 7.0.1
                    
#r "nuget: Oakrey.Applications.Performance, 7.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 Oakrey.Applications.Performance@7.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=Oakrey.Applications.Performance&version=7.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Performance&version=7.0.1
                    
Install as a Cake Tool

Oakrey.Applications.Performance

A .NET 10 Windows library for observing application CPU and RAM usage through Rx streams.

NuGet package ID: Oakrey.Applications.Performance

Main features

  • CpuUsage exposes the latest CPU percentage as IObservable<int>.
  • RamUsage exposes the latest RAM usage in MB as IObservable<int>.
  • Usage exposes the original combined PerformanceLog stream.
  • CPU and RAM streams immediately publish an initial value of zero to new subscribers.
  • The polling period is configurable and must be greater than zero.
  • PerformanceMonitoringLoggingService logs samples using placeholder-based Oakrey logging.
  • Monitoring, subscriptions, subjects, and the underlying Windows monitor have idempotent cleanup.
  • Source errors are logged and forwarded to the derived CPU and RAM streams.

Architecture

classDiagram
    class IPerformanceMonitoringService {
        +IObservable~int~ CpuUsage
        +IObservable~int~ RamUsage
        +IObservable~PerformanceLog~ Usage
    }

    class PerformanceMonitoringService {
        +PerformanceMonitoringService()
        +PerformanceMonitoringService(msPeriod)
        +Dispose()
    }

    class PerformanceMonitoringLoggingService {
        +Preload(cancellationToken) Task
        +Subscribe(observer) IDisposable
        +Dispose()
    }

    IPerformanceMonitoringService <|.. PerformanceMonitoringService
    PerformanceMonitoringLoggingService --> IPerformanceMonitoringService

No public interface signatures are changed by the current implementation.

Requirements and direct dependencies

  • .NET 10 for Windows
  • Oakrey.Debug.Windows 3.0.1
  • Oakrey.Log.Abstractions 3.0.0
  • System.Reactive 6.1.0
  • Project reference to Oakrey.Applications.Abstractions for IPreLoadable and PreLoadingException

All package references are direct, current, and checked for known vulnerabilities.

Installation

dotnet add package Oakrey.Applications.Performance

Package Manager Console:

Install-Package Oakrey.Applications.Performance

Usage

using Oakrey.Applications.Performance;

using PerformanceMonitoringService monitoring =
    new(msPeriod: 1000);

using IDisposable cpuSubscription = monitoring.CpuUsage.Subscribe(
    cpu => Console.WriteLine($"CPU: {cpu}%"));

using IDisposable ramSubscription = monitoring.RamUsage.Subscribe(
    ram => Console.WriteLine($"RAM: {ram} MB"));

The native monitor can require an initialization period before its first sampled value. The initial zero from each BehaviorSubject is available immediately.

Automatic logging

using PerformanceMonitoringService monitoring = new();
using PerformanceMonitoringLoggingService logging = new(monitoring);

await logging.Preload(cancellationToken);

The logging service subscribes during construction and records each combined sample at information level:

CPU: {0}%, RAM: {1} MB

The placeholders are formatted by the Oakrey logger with CPU and RAM supplied as separate arguments.

Dependency injection

services.AddSingleton<IPerformanceMonitoringService, PerformanceMonitoringService>();
services.AddSingleton<PerformanceMonitoringLoggingService>();

Register the concrete monitoring service for disposal when callers also need to resolve it directly. The current IPerformanceMonitoringService contract does not inherit IDisposable.

Lifecycle and safety notes

  • A non-positive polling period throws ArgumentOutOfRangeException.
  • Observable wrappers are cached instead of allocated on every property access.
  • Performance callbacks and disposal are synchronized.
  • Subscriber failures are logged without stopping cleanup of the other streams.
  • Source errors are propagated through CpuUsage and RamUsage.
  • Disposal is safe to call more than once.
  • Preload respects an already-cancelled token and rejects use after disposal.
  • The preload exception replay buffer is limited to one item and is completed during disposal.
  • Information-level sample logging can produce significant log volume at short polling periods. Choose the period according to operational needs.
  • CPU and RAM measurements are operational metadata. Consider access controls and retention policy when exporting logs.

License

MIT - Copyright (c) Oakrey 2016-present

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

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
7.0.1 39 8/6/2026
7.0.0 107 7/20/2026
6.0.2 104 7/8/2026
6.0.1 104 7/3/2026
6.0.0 110 5/22/2026
2.0.4 109 5/22/2026
2.0.3 114 5/15/2026
2.0.2 171 3/13/2026
2.0.1 130 2/11/2026
2.0.0 462 11/18/2025
1.0.2 242 9/29/2025
1.0.1 311 8/8/2025
1.0.0 315 8/6/2025