Skip to content

Instantly share code, notes, and snippets.

@alexyakunin
Last active October 6, 2015 01:45
Show Gist options
  • Save alexyakunin/6c17fcba8a083b47e683 to your computer and use it in GitHub Desktop.
Save alexyakunin/6c17fcba8a083b47e683 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace CSharpAsyncRecursion
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Counted to {0}.", CountRecursivelyAsync(10000).Result);
}
static async Task<int> CountRecursivelyAsync(int count)
{
if (count <= 0)
return count;
return 1 + await CountRecursivelyAsync(count - 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment