diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-07-17 15:03:13 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-07-17 15:03:13 -0500 |
| commit | a8528fd90b0a5636efd859bc841fa28d267ef84f (patch) | |
| tree | d018665297ae541d0e5d6ce8cd654623f22d0f05 /src/slskd/Common | |
| parent | 8432e1395cbe4f5788dec579fbf0516f59847f34 (diff) | |
| parent | 80acf5a658a4c274cb75fa1befd55f5768769c21 (diff) | |
| download | slskd-a8528fd90b0a5636efd859bc841fa28d267ef84f.tar.gz | |
Merge remote-tracking branch 'origin/master' into transfers
Diffstat (limited to 'src/slskd/Common')
| -rw-r--r-- | src/slskd/Common/RateLimiter.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/slskd/Common/RateLimiter.cs b/src/slskd/Common/RateLimiter.cs index a5d1ba45..a93bbebf 100644 --- a/src/slskd/Common/RateLimiter.cs +++ b/src/slskd/Common/RateLimiter.cs @@ -29,7 +29,8 @@ namespace slskd /// Initializes a new instance of the <see cref="RateLimiter"/> class. /// </summary> /// <param name="interval">The minimum interval between invocations.</param> - public RateLimiter(int interval) + /// <param name="flushOnDispose">A value indicating whether pending action(s) should be executed during disposal.</param> + public RateLimiter(int interval, bool flushOnDispose = false) { Timer = new System.Timers.Timer(interval) { @@ -41,9 +42,12 @@ namespace slskd Staged?.Invoke(); Staged = null; }; + + FlushOnDispose = flushOnDispose; } private bool Disposed { get; set; } + private bool FlushOnDispose { get; } private bool Init { get; set; } private Action Staged { get; set; } private System.Timers.Timer Timer { get; set; } @@ -85,7 +89,10 @@ namespace slskd if (disposing) { // if an action is staged, invoke it to 'flush' - Staged?.Invoke(); + if (FlushOnDispose) + { + Staged?.Invoke(); + } Timer.Dispose(); } |
