0

I built a concurrent list class that implements the interfaces IEnumerator<T> and IEnumerable<T>.

My goal is to be able to write:

IEnumrable<string> MyConcurrentList1 = new ConcurrentList<string>();

MyConcurrentList1.AsParallel().MyExtantionMethod_ADD("aaaa");

I want to be able to call the method I wrote in the ConcurrentList<T> from the extenstion method of the ParallelQuery!

Cœur
  • 37,241
  • 25
  • 195
  • 267
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171

1 Answers1

0

I think you mean to ask: how to add a extension method for behind the AsParallel().

It's simple: the method returns a ParallelQuery. So use something like this:

public static class ExtensionMethods
{
    public static void MyExtantionMethod_ADD(this ParallelQuery query, string parameter1)
    {
        ...
    }
}
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • No! its not possibole to use it with out sendding the list we are using at as a parameter to this extenstion method – Stav Alfi Feb 01 '14 at 14:01
  • Which list do you mean? If you mean `MyConcurrentList`, you should not add your extension method to `AsParallel`, but to the list itself. – Patrick Hofman Feb 01 '14 at 14:02
  • I want to be able to call the method I wrote in the ConcurrentList from the extenstion method of the ParallelQuery! is it possibol from your expirience? – Stav Alfi Feb 01 '14 at 14:03
  • Why would you want to do that? What is the relation between the `AsParallel` and the extension method. If you really need to, you can add the list as second parameter, but I wonder why... – Patrick Hofman Feb 01 '14 at 14:04
  • I tought on what you say and you are write. I want to be able to use the ParallelEnumerable methods on my list. There no point to wrtie them fromt he beggining. – Stav Alfi Feb 01 '14 at 14:13