Skip to content

Instantly share code, notes, and snippets.

@joymon
Last active August 29, 2015 14:23
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/06c10ff08b9afb7e45b7 to your computer and use it in GitHub Desktop.
Save joymon/06c10ff08b9afb7e45b7 to your computer and use it in GitHub Desktop.
Write factorial using ADI
private void WriteFactorialAsyncUsingDelegate(int facno)
{
Func<int, int> findFact = FindFactorialWithSimulatedDelay;
findFact.BeginInvoke(facno,
(iAsyncresult) =>
{
AsyncResult asyncResult = iAsyncresult as AsyncResult;
Func<int, int> del = asyncResult.AsyncDelegate as Func<int, int>;
int factorial = del.EndInvoke(asyncResult);
Console.WriteLine("Factorial of {0} is {1}", facno, factorial);
},
null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment