diff --git a/src/Downloader/Packet.cs b/src/Downloader/Packet.cs
index d4d8d68..dd3140c 100644
--- a/src/Downloader/Packet.cs
+++ b/src/Downloader/Packet.cs
@@ -2,24 +2,15 @@
namespace Downloader;
-internal class Packet : IDisposable, ISizeableObject
+internal class Packet(long position, byte[] data, int len) : IDisposable, ISizeableObject
{
- public volatile bool IsDisposed = false;
- public byte[] Data { get; set; }
- public int Length { get; set; }
- public long Position { get; set; }
+ public byte[] Data { get; set; } = data;
+ public int Length { get; set; } = len;
+ public long Position { get; set; } = position;
public long EndOffset => Position + Length;
- public Packet(long position, byte[] data, int len)
- {
- Position = position;
- Data = data;
- Length = len;
- }
-
public void Dispose()
{
- IsDisposed = true;
Data = null;
Position = 0;
}
diff --git a/src/Downloader/PauseToken.cs b/src/Downloader/PauseToken.cs
index 331cd3b..337dc76 100644
--- a/src/Downloader/PauseToken.cs
+++ b/src/Downloader/PauseToken.cs
@@ -2,20 +2,35 @@
namespace Downloader;
-public struct PauseToken
+///
+/// Represents a pause token that can be used to pause and resume operations.
+///
+public record PauseToken
{
private readonly PauseTokenSource _tokenSource;
+
+ ///
+ /// Gets a value indicating whether the operation is paused.
+ ///
public bool IsPaused => _tokenSource?.IsPaused == true;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The pause token source.
internal PauseToken(PauseTokenSource source)
{
_tokenSource = source;
}
+ ///
+ /// Waits asynchronously while the operation is paused.
+ ///
+ /// A task that represents the asynchronous wait operation.
public Task WaitWhilePausedAsync()
{
return IsPaused
? _tokenSource.WaitWhilePausedAsync()
: Task.FromResult(true);
}
-}
+}
\ No newline at end of file