* PLEASE SEE END FOR IMPORTANT EDIT *
For various reasons I have something like:
delegate void Task(QueueTask queueTask);
delegate void QueueTask(Task task);
Using Visual Studio Express 2008 this works more or less fine apart from in lambda expressions where it can't deduce if I try call and call queueTask() in the function without explicit help:
void MyTask(QueueTask queueTask) { queueTask(qt => {}); // fails with queueTask doesn't take 1 parameter? }
This works though:
void MyTask(QueueTask queueTask) { queueTask((QueueTask qt) => {}); }
Its not a huge problem and I know I could also probably get away by passing in another object that contained the delegate instead but I was curious if there was a way to make it work as its stands?
Thanks.
* IMPORTANT EDIT BELOW *
It seems only if I put the class 'TaskPool2' in a separate assembly I get the compile error!?
namespace Test { public class TaskPool2 { public delegate void QueueTask(Task task); public delegate void Task(QueueTask queueTask); public void Queue(Task task) { } } } namespace MyApp { class Program { static void SomeFunc() { Test.TaskPool2 taskPool = new Test.TaskPool2(); taskPool.Queue(queue => { Console.WriteLine("A"); queue(q => Console.WriteLine("C")); }); } } }
Granted its somewhat convoluted!