Last active
April 27, 2016 23:53
-
-
Save kneerunjun/2694b33243a7ba480d027ee32c774244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RoutePrefix("some")] | |
public class SomeController :ApiController{ | |
[HttpGet] | |
[Route("test")] | |
public IHttpActionResult Test(){ | |
Repo repo = new Repo(); | |
var task = repo.GetAll(); | |
task.Wait(); //Im sure this was working in the previous versions but is not now. | |
var allEmps = task.Result; // here it gets lost and has no clue how to come back to this promise | |
return Ok<List<Employee>>(allEmps) | |
} | |
} | |
public class Repo { | |
public async Task<Employee> GetAll(){ | |
//some task here and it woudl be asynchronous | |
} | |
} | |
public class Employee{ | |
//a couple of properties here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RoutePrefix("some")] | |
public class SomeController :ApiController{ | |
[HttpGet] | |
[Route("test")] | |
public Task<IHttpActionResult> Test(){ | |
Repo repo = new Repo(); | |
return Ok<List<Employee>>(await repo.GetAll()); //and now since the action itself is async , this works | |
//very funny its either I have not understood threading in .NET or that MS has changed a few nuts and bolts underneath | |
} | |
} | |
public class Repo { | |
public async Task<Employee> GetAll(){ | |
//some task here and it woudl be asynchronous | |
} | |
} | |
public class Employee{ | |
//a couple of properties here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment