Created
July 6, 2019 13:38
Star
You must be signed in to star a gist
This file contains 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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ConsoleApp166 | |
{ | |
class Program | |
{ | |
static unsafe void Main(string[] args) | |
{ | |
LongContinuationChain_ContinueWith_DoesNotStackOverflow(); | |
Console.WriteLine("Done"); | |
} | |
public static void LongContinuationChain_ContinueWith_DoesNotStackOverflow() | |
{ | |
var tcs = new TaskCompletionSource<bool>(); | |
var t = (Task)tcs.Task; | |
for (int i = 0; i < 12_000; i++) | |
{ | |
t = t.ContinueWith(_ => { }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); | |
} | |
tcs.TrySetResult(true); | |
t.Wait(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment