.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Linq;
using System.Threading.Tasks;

public class Program
{
	static int counter = 0;

	static void Main()
	{
		foreach (int i in Enumerable.Range(0,100).ToArray())
			counter = Foo(counter).Result;
		Console.WriteLine(counter);
	}

	static async Task<int> Foo(int counter)
	{
		for(int i = 0; i < 100000; i++)
			counter = Set(counter);
		return counter;
	}
	
	static int Set(int counter)
	{
		return ++counter;
	}
}
;