Skip to content

Commit

Permalink
added .netstandard2.1 to supported .Net version of the Downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Oct 4, 2024
1 parent a50963c commit bf25391
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

:rocket: Fast, cross-platform and reliable multipart downloader with **.Net Core** supporting :rocket:

Downloader is a modern, fluent, asynchronous, testable and portable library for .NET. This is a multipart downloader with asynchronous progress events.
This library can be added to your `.Net 8` or later projects.
**Downloader** is a modern, fluent, asynchronous, and portable library for .NET, designed with testability in mind.
It supports multipart downloads with real-time asynchronous progress events.
The library is compatible with projects targeting `.NET Standard 2.1`, `.NET 8`, and later versions.

Downloader is running on Windows, Linux, and macOS.
> Note: Support for old versions of `.NET` was removed from the Downloader `v3.2.0`. From this version onwards, `only .Net 8 and higher versions` will be supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task TestReadStreamSpeed(int speedX, bool asAsync)
while (readSize > 0)
{
readSize = asAsync
? await stream.ReadAsync(buffer, 0, buffer.Length, new CancellationToken()).ConfigureAwait(false)
? await stream.ReadAsync(buffer, 0, buffer.Length, new CancellationToken())
: stream.Read(buffer, 0, buffer.Length);
totalReadSize += readSize;

Expand Down
10 changes: 8 additions & 2 deletions src/Downloader/ConcurrentStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ public ConcurrentStream(Stream stream, long maxMemoryBufferBytes = 0, ILogger lo
/// <param name="initSize">The initial size of the file.</param>
/// <param name="maxMemoryBufferBytes">The maximum amount of memory, in bytes, that the stream is allowed to allocate for buffering.</param>
/// <param name="logger">The logger to use for logging.</param>
public ConcurrentStream(string filename, long initSize, long maxMemoryBufferBytes = 0, ILogger logger = null) : base(logger)
public ConcurrentStream(string filename, long initSize, long maxMemoryBufferBytes = 0, ILogger logger = null) :
base(logger)
{
_path = filename;
_stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
Expand Down Expand Up @@ -228,7 +229,8 @@ private async Task Watcher()
StartState();
while (!_watcherCancelSource.IsCancellationRequested)
{
await _inputBuffer.WaitTryTakeAsync(_watcherCancelSource.Token, WritePacketOnFile).ConfigureAwait(false);
await _inputBuffer.WaitTryTakeAsync(_watcherCancelSource.Token, WritePacketOnFile)
.ConfigureAwait(false);
}
}
catch (Exception ex) when (ex is TaskCanceledException || ex is OperationCanceledException)
Expand Down Expand Up @@ -324,7 +326,11 @@ public async ValueTask DisposeAsync()
if (!_disposed)
{
_disposed = true;
#if NET8_0_OR_GREATER
await _watcherCancelSource.CancelAsync().ConfigureAwait(false); // request the cancellation
#else
_watcherCancelSource.Cancel(); // request the cancellation
#endif
await _stream.DisposeAsync().ConfigureAwait(false);
_inputBuffer.Dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Downloader/Downloader.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;netstandard2.1;</TargetFrameworks>
<LangVersion>latestMajor</LangVersion>
<Version>3.2.0</Version>
<AssemblyVersion>3.2.0</AssemblyVersion>
Expand Down

0 comments on commit bf25391

Please sign in to comment.