Last active
August 29, 2015 14:23
-
-
Save joymon/edbef6f7cbee8078c273 to your computer and use it in GitHub Desktop.
Writes the factorial by awaiting on FindFactorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task WriteFactorialAsyncUsingAwait(int facno) | |
{ | |
int result = await Task.Run(()=> FindFactorialWithSimulatedDelay(facno)); | |
Console.WriteLine("Factorial of {0} is {1}", facno, result); | |
} | |
public void Main() | |
{ | |
for (int counter = 1; counter < 5; counter++) | |
{ | |
if (counter % 3 == 0) | |
{ | |
WriteFactorialAsyncUsingAwait(counter); | |
} | |
else | |
{ | |
Console.WriteLine(counter); | |
} | |
} | |
Console.ReadLine(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment