From c991bf1c1b90cd7888469c607009d91a9222802e Mon Sep 17 00:00:00 2001 From: bezzad Date: Wed, 18 Sep 2024 18:23:46 +0330 Subject: [PATCH] add xml doc to PauseTokenSource.cs file --- src/Downloader/PauseTokenSource.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Downloader/PauseTokenSource.cs b/src/Downloader/PauseTokenSource.cs index 202d715..3f8c07d 100644 --- a/src/Downloader/PauseTokenSource.cs +++ b/src/Downloader/PauseTokenSource.cs @@ -3,19 +3,35 @@ namespace Downloader; +/// +/// Represents a source for creating and managing pause tokens. +/// public class PauseTokenSource { private volatile TaskCompletionSource _tcsPaused; + /// + /// Gets the pause token associated with this source. + /// public PauseToken Token => new PauseToken(this); + + /// + /// Gets a value indicating whether the operation is paused. + /// public bool IsPaused => _tcsPaused != null; + /// + /// Pauses the operation by creating a new task completion source. + /// public void Pause() { // if (tcsPause == null) tcsPause = new TaskCompletionSource(); Interlocked.CompareExchange(ref _tcsPaused, new TaskCompletionSource(), null); } + /// + /// Resumes the operation by setting the result of the task completion source and resetting it. + /// public void Resume() { // we need to do this in a standard compare-exchange loop: @@ -38,8 +54,12 @@ public void Resume() } } + /// + /// Waits asynchronously while the operation is paused. + /// + /// A task that represents the asynchronous wait operation. internal Task WaitWhilePausedAsync() { return _tcsPaused?.Task ?? Task.FromResult(true); } -} +} \ No newline at end of file