Stopping Parallel.ForEach with Cancellation Token and Stop
问题 I'm not sure if I'm stopping a Parallel.ForEach loop as I intend to do. So let me outline the problem. The loop uses a database driver with limited available connections and it is required to keep track of the open connections, so the database driver doesn't throw an exception. The issue is that keeping track of open connections has been implemented manually (this should be refactored - writing a wrapper or using AutoResetEvent but there are some other things that need to be taken care of