![]() |
VOOZH | about |
dotnet add package Oakrey.Applications.UsbNotifying --version 2.0.5
NuGet\Install-Package Oakrey.Applications.UsbNotifying -Version 2.0.5
<PackageReference Include="Oakrey.Applications.UsbNotifying" Version="2.0.5" />
<PackageVersion Include="Oakrey.Applications.UsbNotifying" Version="2.0.5" />Directory.Packages.props
<PackageReference Include="Oakrey.Applications.UsbNotifying" />Project file
paket add Oakrey.Applications.UsbNotifying --version 2.0.5
#r "nuget: Oakrey.Applications.UsbNotifying, 2.0.5"
#:package Oakrey.Applications.UsbNotifying@2.0.5
#addin nuget:?package=Oakrey.Applications.UsbNotifying&version=2.0.5Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.UsbNotifying&version=2.0.5Install as a Cake Tool
A Windows-only .NET library that monitors USB device arrival and removal events using the
Windows PnP notification API and exposes them as a reactive IObservable<UsbEventArgs> stream.
DeviceNotificationListener from Nefarius.Utilities.DeviceManagement � no raw Win32 interop required.IObservable<UsbEventArgs> via IUsbNotifyingService.ReplaySubject<UsbEventArgs>(1) � late subscribers receive the most recent event immediately.Oakrey.Log.IDisposable � properly unregisters listeners and disposes subjects.classDiagram
IObservable~UsbEventArgs~ <|-- IUsbNotifyingService
IUsbNotifyingService <|.. UsbNotifyingService
IDisposable <|.. UsbNotifyingService
UsbNotifyingService --> DeviceNotificationListener : wraps
UsbNotifyingService --> ReplaySubject~UsbEventArgs~ : broadcasts via
// Service interface � subscribe to receive USB events
public interface IUsbNotifyingService : IObservable<UsbEventArgs> { }
// Concrete service � register with DI or instantiate directly
public sealed class UsbNotifyingService : IUsbNotifyingService, IDisposable
{
public UsbNotifyingService();
public IDisposable Subscribe(IObserver<UsbEventArgs> observer);
public void Dispose();
}
UsbEventArgs is provided by Oakrey.Usb and carries:
DeviceInfo.VID � vendor identifierDeviceInfo.PID � product identifierDeviceInfo.DeviceId � symbolic link / serial numberUsbDeviceChangeStatus � INSERTED or REMOVEDNefarius.Utilities.DeviceManagement 5.2.xOakrey.Usb 3.0.xOakrey.Log 2.0.xSystem.Reactive 6.1.x.NET CLI
dotnet add package Oakrey.Applications.UsbNotifying
Package Manager Console
Install-Package Oakrey.Applications.UsbNotifying
NuGet Package Manager UI
Search for Oakrey.Applications.UsbNotifying in Visual Studio under
Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
using Oakrey.Applications.UsbNotifying;
await using UsbNotifyingService service = new();
IDisposable subscription = service.Subscribe(e =>
{
Console.WriteLine($"{e.UsbDeviceChangeStatus}: VID={e.DeviceInfo.VID} PID={e.DeviceInfo.PID}");
});
// Keep the application alive; dispose subscription when done.
subscription.Dispose();
services.AddSingleton<IUsbNotifyingService, UsbNotifyingService>();
public sealed class MyHandler
{
private readonly IDisposable subscription;
public MyHandler(IUsbNotifyingService usbService)
{
subscription = usbService.Subscribe(e =>
{
if (e.UsbDeviceChangeStatus == UsbDeviceChangeStatus.INSERTED)
{
// handle device arrival
}
});
}
}
DeviceNotificationListener calls Win32 PnP APIs.
The target framework net10.0-windows enforces this at build time.ReplaySubject(1) means any subscriber that registers after the last event still
receives it immediately. Use a fresh Subject<T> instead if that behaviour is undesirable.DeviceNotificationListener.StartListen is called for DeviceInterfaceIds.UsbDevice.
To monitor a different device class, derive from or wrap UsbNotifyingService and
pass a different Guid to StartListen.MIT. Copyright (c) Oakrey 2016-present.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 net10.0-windows7.0 is compatible. |
Showing the top 1 NuGet packages that depend on Oakrey.Applications.UsbNotifying:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.Ohm.CAN
Service layer library for managing CAN bus hardware devices and channels. Provides device discovery, connection lifecycle management, reactive IObservable streams for received frames and status changes, per-channel transmit, USB hot-plug detection, and persistent JSON configuration. |
This package is not used by any popular GitHub repositories.