Skip to content

Instantly share code, notes, and snippets.

@meklarian
Last active December 15, 2015 17:20
Show Gist options
  • Select an option

  • Save meklarian/5296095 to your computer and use it in GitHub Desktop.

Select an option

Save meklarian/5296095 to your computer and use it in GitHub Desktop.
ad hoc parallel lambdas
namespace Namespace
{
public static class Foo
{
public static void Parallel(params Action[] bars)
{
bars.AsParallel().ForAll((a) => { if (null != a) { a(); } });
System.Threading.Thread.MemoryBarrier();
}
}
}
// syntactic sugar, lets you do arbitrary bits in parallel
Foo.Parallel(
()=>{someWorkHere();},
()=>{someWorkThere();},
()=>{everyWhereWorkBlahBlah();}
);
// which is really nice with closures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment