Skip to content

Instantly share code, notes, and snippets.

@DamianEdwards
Created February 4, 2012 01:41
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 DamianEdwards/1734345 to your computer and use it in GitHub Desktop.
Save DamianEdwards/1734345 to your computer and use it in GitHub Desktop.
Crazy TPL helper from SignalR for the day
public static Task Interleave<T>(Func<T, Action, Task> before, Func<Task> after, T arg)
{
var tcs = new TaskCompletionSource<object>();
var tasks = new[] {
tcs.Task,
before(arg, () => after().ContinueWith(tcs))
};
return tasks.Return();
}
@paulbatum
Copy link

What the hell does this do? I don't even know what Task[].Return() does. But let me guess - its YESTERDAY's crazy TPL helper for SignalR. Right? :)

@DamianEdwards
Copy link
Author

DamianEdwards commented Feb 7, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment