How to construct a Task without starting it?

var t = new Task<int>(() => GetIntAsync("3").Result);


var t = new Task<int>((ob) => GetIntAsync((string) ob).Result, "3");

To avoid using lambda, you need to write a static method like this:

private static int GetInt(object state)
   return GetIntAsync(((string) state)).Result;

And then:

var t = new Task<int>(GetInt, "3");

Leave a Comment