Skip to content

Instantly share code, notes, and snippets.

@wwahammy
Created March 13, 2012 21:55
Show Gist options
  • Save wwahammy/2032015 to your computer and use it in GitHub Desktop.
Save wwahammy/2032015 to your computer and use it in GitHub Desktop.
Holy cow
/// <summary>
/// TODO: holy cow, is this confusing
/// </summary>
public Task<IEnumerable<string>> SystemFeeds
{
get
{
var tcs = new TaskCompletionSource<IEnumerable<string>>();
var list = new List<string>();
Pm.ListFeeds(default(int?), default(int?),
new PackageManagerMessages{
Error = (a, b, c) => tcs.SetException(new Exception()),
NoFeedsFound = () => tcs.SetResult(Enumerable.Empty<string>()),
FeedDetails = (s, d, b1, b2, b3) =>
{
if (!b1)
lock (list)
{
list.Add(s);
}
}
}).ContinueWith((t) =>
{
if (tcs.Task.IsCompleted || tcs.Task.IsFaulted)
{
//no feeds!
}
else
{
tcs.SetResult(list);
}
});
return tcs.Task;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment