Created
September 14, 2016 08:47
-
-
Save andrewlock/404fa531384a2a73418de59aeaa9ced2 to your computer and use it in GitHub Desktop.
Getting a Task when you don't expect it
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
public class UserService | |
{ | |
private readonly IUserRepo _repo; | |
public UserService(IUserRepo repo) | |
{ | |
_repo = repo; | |
} | |
public async Task<bool> DoesUserExist(int userId) | |
{ | |
//some async method, which is awaited, so no compiler warnings | |
var something = await _repo.SomeMethodAsync(userId); | |
// GetUser is an Async method returning a Task<User> | |
var user = _repo.GetUser(userId); | |
// Oops, this is always false | |
return user == null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment