This commit is contained in:
Stef Heyenrath
2019-09-17 18:13:01 +02:00
committed by GitHub
parent 5b8b588983
commit e1798fbb8e
7 changed files with 23 additions and 13 deletions

View File

@@ -1,14 +1,15 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace WireMock.Util
{
/// <summary>
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe.
/// </summary>
/// <typeparam name="T">The type of elements in the collection.</typeparam>
/// <inheritdoc cref="ObservableCollection{T}" />
public class ConcurrentObservableCollection<T> : ObservableCollection<T>
internal class ConcurrentObservableCollection<T> : ObservableCollection<T>
{
private readonly object _lockObject = new object();
@@ -73,5 +74,13 @@ namespace WireMock.Util
base.MoveItem(oldIndex, newIndex);
}
}
public List<T> ToList()
{
lock (_lockObject)
{
return Items.ToList();
}
}
}
}