tags:

views:

79

answers:

1

I'm using the Concurrency and Coordination Runtime and am writing code similar to what is described in the documentation. The following line fails to compile:

yield return new IterativeTask<string,Object,Object,long[]>("Hi",a,b,ls, itfunc);

The compiler gives this error message:

The non-generic type 'Microsoft.Ccr.Core.IterativeTask' cannot be used with type arguments

Which is mistifying because the documentation uses that method with type arguments and it's clearly generic.

(I'm going to post my own answer here, that's encouraged as I understand it)

+2  A: 

It turns out that there is a limit to the number of generic parameters one can use with IterativeTask: it can take three but no more.

So, this code compiles (once you change itfunc to use one fewer argument):

yield return new IterativeTask<string,Object,long[]>("Hi",a,ls, itfunc);

If you really do need all the information in the arguments, you can create some type to hold them:

struct Z {
  string msg;
  Object one;
  Object two;
  long[] ls;
}

Z z = new Z { msg="Hi", one=a, two=b, ls= longs };
yield return new IterativeTask<Z>(z, itfunc);
redtuna