Is there a way in C# 4.0 to have a method take a delegate with the parameters baked in?
Posted
by Rob Packwood
on Stack Overflow
See other posts from Stack Overflow
or by Rob Packwood
Published on 2010-04-10T22:58:41Z
Indexed on
2010/04/10
23:03 UTC
Read the original article
Hit count: 166
c#4.0
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?
© Stack Overflow or respective owner