Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Created February 20, 2012 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeGinnivan/1868074 to your computer and use it in GitHub Desktop.
Save JakeGinnivan/1868074 to your computer and use it in GitHub Desktop.
public Task<User> GetUser()
{
return NGitHub(_client.Users.GetAuthenticatedUserAsync)
}
public Task<T> NGitHub<T>(Func<Action<T>, Action<Exception>, GitHubRequestAsyncHandle> call)
{
var _client = new GitHubClient
{
Authenticator = new HttpBasicAuthenticator("user", "pass")
};
var completionSource = new TaskCompletionSource<User>();
call(completionSource.SetResult, completionSource.SetException);
return completionSource.Task;
}
public Task<T> NGitHub<T, TArg>(Func<TArg, Action<T>, Action<Exception>, GitHubRequestAsyncHandle> call, TArg arg)
{
var _client = new GitHubClient
{
Authenticator = new HttpBasicAuthenticator("user", "pass")
};
var completionSource = new TaskCompletionSource<User>();
call(arg, completionSource.SetResult, completionSource.SetException);
return completionSource.Task;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment