// see the MutexFun project TODO: REOWRK USING System.IO.MemoryMappedFiles.MemoryMappedFile #endregion #region "12.8 Using events to make threads cooperate" public static void TestResetEvent() { // We have a diner with a cook who can only serve up one meal at a time Cook Mel = new Cook() { Name = "Mel" }; string[] waitressNames = { "Flo", "Alice", "Vera", "Jolene", "Belle" }; // Have waitresses place orders foreach (var waitressName in waitressNames) { Task.Run(() => { // The Waitress places the order and then waits for the order Waitress.PlaceOrder(waitressName, Cook.OrderReady); }); } // Have the cook fill the orders for (int i = 0; i < waitressNames.Length; i++) { // make the waitresses wait... Thread.Sleep(2000); // ok, next waitress, pickup! Mel.CallWaitress(); } }