Your stacking is not big enough.
You can increase the default stacking by starting a new thread and define a new stacksize in the constructor:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; namespace ConsoleApplication3 { class Program { private static int i = 0; static void Main(string[] args) { Thread T = new Thread(DoSomething, 100000000); T.Start(); Console.ReadLine(); } public static void DoSomething() { Console.WriteLine(i); ++i; DoSomething(); } } }
Stackoverflow now comes with 1.5 million recursive calls.
source share