Soenneker.MemoryStream.ManualClose
4.0.693
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.MemoryStream.ManualClose --version 4.0.693
NuGet\Install-Package Soenneker.MemoryStream.ManualClose -Version 4.0.693
<PackageReference Include="Soenneker.MemoryStream.ManualClose" Version="4.0.693" />
<PackageVersion Include="Soenneker.MemoryStream.ManualClose" Version="4.0.693" />
<PackageReference Include="Soenneker.MemoryStream.ManualClose" />
paket add Soenneker.MemoryStream.ManualClose --version 4.0.693
#r "nuget: Soenneker.MemoryStream.ManualClose, 4.0.693"
#:package Soenneker.MemoryStream.ManualClose@4.0.693
#addin nuget:?package=Soenneker.MemoryStream.ManualClose&version=4.0.693
#tool nuget:?package=Soenneker.MemoryStream.ManualClose&version=4.0.693
Soenneker.MemoryStream.ManualClose
A MemoryStream whose Close and Dispose calls can be temporarily ignored when another API incorrectly assumes ownership of a caller-owned stream.
Installation
dotnet add package Soenneker.MemoryStream.ManualClose
Usage
AllowClose defaults to true, so the stream behaves like a normal MemoryStream unless closing is explicitly blocked.
var stream = new ManualCloseMemoryStream
{
AllowClose = false
};
try
{
await WritePayload(stream);
// This dependency calls Dispose on the supplied stream.
await SendWithoutOwnership(stream);
// The stream remains usable because closing was blocked.
stream.Position = 0;
await SaveCopy(stream);
}
finally
{
stream.AllowClose = true;
stream.Dispose();
}
Always restore AllowClose and dispose in a finally block. While closing is blocked, a using statement or an early Dispose call does not release the stream's buffer.
This type is useful only when an API closes a stream it does not own and offers no leave-open option. Prefer the dependency's native leaveOpen setting when one exists. Do not change AllowClose concurrently with disposal; the property does not provide synchronization.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.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 |
|---|---|---|
| 4.0.696 | 40 | 9/24/2026 |
| 4.0.695 | 168 | 9/15/2026 |
| 4.0.694 | 94 | 9/12/2026 |
| 4.0.693 | 129 | 8/30/2026 |
| 4.0.692 | 99 | 8/29/2026 |
| 4.0.691 | 303 | 7/27/2026 |
| 4.0.690 | 118 | 7/16/2026 |
| 4.0.689 | 1,303 | 6/18/2026 |
| 4.0.688 | 214 | 6/5/2026 |
| 4.0.687 | 129 | 6/5/2026 |
| 4.0.685 | 485 | 3/12/2026 |
| 4.0.684 | 140 | 3/12/2026 |
| 4.0.683 | 142 | 3/12/2026 |
| 4.0.682 | 142 | 3/12/2026 |
| 4.0.681 | 148 | 3/10/2026 |
| 4.0.680 | 143 | 3/9/2026 |
| 4.0.679 | 137 | 3/9/2026 |
| 4.0.678 | 140 | 3/9/2026 |
| 4.0.677 | 349 | 3/4/2026 |
| 4.0.676 | 335 | 1/2/2026 |
Document manual stream ownership