I am entering someone else's codebase in c# as a previously c++ coder. All over his code I find snippets that look like this:
MethodInvoker invoker = new MethodInvoker
(delegate()
{
...
}
);
try
{
this.Invoke(invoker);
}
catch (Exception x)
{
...
}
My question is: Is there any reason to be using a delegate
and then the try-catch? Can the code inside the curly braces on the third to fifth lines not just be placed inside that try catch? Is there some nuance of c# I do not yet know?