BlockingCollection.Dispose实际上做了什么?

Jon*_*len 8 .net .net-4.0

BlockingCollection.Dispose实际上做了什么?

Ree*_*sey 11

这允许正确处理内部等待句柄.

BlockingCollection<T>在内部,使用一对事件等待句柄,而这些句柄又具有关联的本机HANDLE.

具体来说,BlockingCollection<T>.Dispose()最终(通过SemaphoreSlim-> ManualResetEvent)在两个本机实例上调用本机CloseHandle方法,将这两个句柄释放回操作系统HANDLE.