Is there a way in C# 4.0 to have a method take a delegate with the parameters baked in?
- by Rob Packwood
I have this code for reporting on a simple demo app I am writing:
private static void ReportOnTimedProcess(Action process)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
process();
stopwatch.Stop();
Console.WriteLine("Process took {0} seconds",
stopwatch.ElapsedMilliseconds*1000);
}
I basically want to track the time of any process. I am trying to have this method take a delegate as a parameter that can have any number of varying parameters. Is there some way an Expression can do this?