Skip to content

Commit 8966732

Browse files
committed
释放异步解决内存泄露
1 parent c2ecd8f commit 8966732

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

AsyncWorkerCollection/AsyncQueue.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public void Dispose()
8787
// 此时将会在 DequeueAsync 进入 TryDequeue 方法,也许此时依然有开发者在 _queue.Clear() 之后插入元素,但是没关系,我只是需要保证调用 Dispose 之后会让 DequeueAsync 方法返回而已
8888
_isDisposed = true;
8989
_queue.Clear();
90+
// 释放 DequeueAsync 方法
91+
_semaphoreSlim.Release(int.MaxValue);
9092
_semaphoreSlim.Dispose();
9193
}
9294

0 commit comments

Comments
 (0)