change its foreach

0.9.1.0-post-fixes
UbitUmarov 2019-01-06 02:23:49 +00:00
parent 54b4523da8
commit 6e60917522
1 changed files with 5 additions and 21 deletions

View File

@ -329,29 +329,13 @@ namespace OpenSim.Framework
public void ForEach(Action<TValue> action) public void ForEach(Action<TValue> action)
{ {
bool gotLock = false; TValue[] values = GetArray();
if(values == null || values.Length == 0)
return;
try foreach (TValue value in values)
{
// Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
// the acquision inside the main try. The inner finally block is needed because thread aborts cannot
// interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
try {}
finally
{
rwLock.EnterReadLock();
gotLock = true;
}
foreach (TValue value in Dictionary1.Values)
action(value); action(value);
} }
finally
{
if (gotLock)
rwLock.ExitReadLock();
}
}
public void ForEach(Action<KeyValuePair<TKey1, TValue>> action) public void ForEach(Action<KeyValuePair<TKey1, TValue>> action)
{ {