0

I have this code

static void TaskRun(Action action)
{
    Task.Run(() => { try { action();} catch {}});
}

static void Run()
{
    TaskRun(() => {int a =5; a = a *5;})
}

I want to get the content of the action parameters as string (e.g. "int a =5; a = a *5;") in my TaskRun function.

The reason is that i want to wrap all the Task.run with the try catch and in my catch i want to print the code that causes the crash

asaf
  • 958
  • 1
  • 16
  • 38
  • Are you asking for a way to convert any delegate body into string? – Zoran Horvat Jan 14 '17 at 16:49
  • 2
    Possible duplicate of [.NET - dump statement lambda body to string](http://stackoverflow.com/questions/4922307/net-dump-statement-lambda-body-to-string) – GSerg Jan 14 '17 at 16:49

0 Answers0