I am facing a problem with the async main feature of c# 7.1.
Here is a github link to a sample project to demonstrate the problem: https://github.com/xorpherion/CSharpAsyncMainProblem
The code is used as part of a gameloop. As you can see the main signature uses async so behind the scenes a synchronization context is created.
The Timedloop class is kind of a timer that tries to schedule an event (OnTick) when the current time exceeds a limit. There are 3 methods to trigger the event: SpinLoop, WaitLoopAsync and WaitLoop. SpinLoop and WaitLoop behave as expected ( single threaded scheduling of OnTick). The problem lies with WaitLoopAsync. What i am expecting here is to also stay on the current thread as .ConfigureAwait is not set to "false". But when you run the code you will see messages on the console that the thread id changes. This does not happen with the other loop "types".
My question here: Why is the continuation not scheduled on the same thread?
I am running this on .net core 2.1.