[C#] AutoResetEvent solution
\nusing System;\nusing System.Threading;\n\npublic class FooBar \n{\n    private int n;\n\n    private AutoResetEvent fooEvent = new AutoResetEvent(true);\n    
```\nusing System;\nusing System.Threading;\n\npublic class FooBar \n{\n    private int n;\n\n    private AutoResetEvent fooEvent = new AutoResetEvent(true);\n    private AutoResetEvent barEvent = new AutoResetEvent(false);\n    \n    public FooBar(int n) \n    {\n        this.n = n;\n    }\n\n    public void Foo(Action printFoo) \n    { \n        for (int i = 0; i < n; i++) \n        {\n            fooEvent.WaitOne();\n        \tprintFoo();\n            barEvent.Set();\n        }\n    }\n\n    public void Bar(Action printBar) \n    {\n        for (int i = 0; i < n; i++) \n        {\n            barEvent.WaitOne();\n        \tprintBar();\n            fooEvent.Set();\n        }\n    }\n}\n```
[]