Skip to content

Instantly share code, notes, and snippets.

@DamianEdwards
Created February 4, 2012 01:41
Show Gist options
  • 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();
}
@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