Thread safety on async/await with memory caching
问题 I was having a look at the section on memory barriers as described in http://www.albahari.com/threading/part4.aspx and attempted to make an async/await version of the example provided under 'Do We Really Need Locks and Barriers?': public class Program { static void Main(string[] args) { TestAsync(); Console.ReadKey(true); } private static async void TestAsync() { bool complete = false; Func<Task> testFunc = async () => { await Task.Delay(1000); bool toggle = false; while (!complete) toggle =