+ Execute and store the results of the Linq query as a List to prevent collection modified exceptions.
* The List is a member of PooledEnumerable<T> and is thus pooled along with it.
This commit is contained in:
parent
af86aa23c7
commit
a32c4573ad
1 changed files with 7 additions and 4 deletions
|
|
@ -1743,7 +1743,7 @@ namespace Server
|
|||
|
||||
if (e != null)
|
||||
{
|
||||
e._Pool = pool;
|
||||
e._Pool.AddRange(pool);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1754,11 +1754,11 @@ namespace Server
|
|||
}
|
||||
|
||||
private bool _IsDisposed;
|
||||
private IEnumerable<T> _Pool;
|
||||
private List<T> _Pool;
|
||||
|
||||
public PooledEnumerable(IEnumerable<T> pool)
|
||||
{
|
||||
_Pool = pool;
|
||||
_Pool = new List<T>(pool);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
|
|
@ -1778,7 +1778,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
_Pool = null;
|
||||
_Pool.Clear();
|
||||
|
||||
lock (((ICollection)_Buffer).SyncRoot)
|
||||
{
|
||||
|
|
@ -1789,6 +1789,9 @@ namespace Server
|
|||
public void Dispose()
|
||||
{
|
||||
_IsDisposed = true;
|
||||
|
||||
_Pool.Clear();
|
||||
_Pool.TrimExcess();
|
||||
_Pool = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue