I need a threadsafe implementation of list, so I created an override for all list functionality and implemented all (useful) Linq functions and surrounded them with a lock. The only Linq function that I fail to implement is Select.
This is what the Select function looks like in the Linq implementation
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector);
I try to override that. It can be seen that select requires to use T and TResult, but to override the list implementation I only have T. This is what I tried so far:
public partial class ThreadSafeList<T> : List<T>
{
public object _lock = new object();
public IEnumerable<TResult> Select(Func<T, TResult> selector)
{
lock (_lock)
{
return System.Linq.Enumerable.Select(this, selector);
}
}
}
But TResult does not exist. Any ideas on how I can override the Linq Select implementation?