"Access to disposed closure" warning when calling ParallelEnumerable.ToDictionary()

Answered

I get an "Access to disposed closure" warning from R# 2016.1.1 in VS 2015 when calling ParallelEnumerable.ToDictionary(), but not when calling Enumerable.ToDictionary(), i.e.

using (myDisposable)
{
    myEnumerable.ToDictionary(k => k, v => DoSomething(v, myDisposable)); // OK
    myEnumerable.AsParallel().ToDictionary(k => k, v => DoSomething(v, myDisposable)); // "Access to disposed closure"
}

Those two should be treated the same way, shouldn't they? AsParallel().ToDictionary() will still enumerate the entire myEnumerable before Dispose() is called on myDisposable.

2 comments
Comment actions Permalink
Official comment

Hello Evgeny,

We filed a new https://youtrack.jetbrains.com/issue/RSRP-458828 ticket, you may follow it.

Thanks! 

Please sign in to leave a comment.