Skip to content

Commit 0df34c1

Browse files
authored
Merge pull request #12 from dotnet-campus/t/lindexi/FixMemory
释放异步解决内存泄露
2 parents c2ecd8f + 8966732 commit 0df34c1

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)