Async/await as a replacement of coroutines
I use C# iterators as a replacement for coroutines, and it has been working great. I want to switch to async/await as I think the syntax is cleaner and it gives me type safety. In this (outdated) blog post, Jon Skeet shows a possible way to implement it . I chose to go a slightly different way (by implementing my own SynchronizationContext and using Task.Yield ). This worked fine. Then I realized there would be a problem; currently a coroutine doesn't have to finish running. It can be stopped gracefully at any point where it yields. We might have code like this: private IEnumerator Sleep(int