Skip to content

Instantly share code, notes, and snippets.

@joymon
Created June 24, 2015 16:17
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 joymon/b2a908226782e6b5aa7e to your computer and use it in GitHub Desktop.
Save joymon/b2a908226782e6b5aa7e to your computer and use it in GitHub Desktop.
Writes factorial using TPL
private void WriteFactorialAsyncUsingTask(int no)
{
Task<int> task=Task.Run<int>(() =>
{
int result = FindFactorialWithSimulatedDelay(no);
return result;
});
task.ContinueWith(new Action<Task<int>>((input) =>
{
Console.WriteLine("Factorial of {0} is {1}", no, input.Result);
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment