//works Task.Run(() => TestTasks.CustomTasks.DummyTask()); //does not work TestHelpers.Tasks.Run(TestTasks.CustomTasks.DummyTask);
namespace TestHelpers { public static class Tasks { public static string Run(Action action) { try { Task.Run(() => action); return "ok"; } catch (Exception ex) { return ex.Message; } } } } namespace TestTasks { public static class CustomTasks { public static void DummyTask() { for (int i = 0; i < 10; i++) System.Threading.Thread.Sleep(100); } } }
Task.Run(() => action);
Task.Run(action);
public static System.Threading.Tasks.Task Run (Action action);
public static void DummyTask(string param) {...}
TestHelpers.Tasks.Run(() => TestTasks.CustomTasks.DummyTask("My parameter"));
Task.Run(action)
Task
Task.Run(() => action());
Task<Action>
TestHelpers.Tasks.Run(new Action(TestTasks.CustomTasks.DummyTask));
TestHelpers.Tasks.Run(TestTasks.CustomTasks.DummyTask);
Task.Run(() => TestTasks.CustomTasks.DummyTask());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)