C# the most correct solution
csharp\nusing System.Threading.Tasks;\n\npublic class Foo\n{\n    private TaskCompletionSource<bool> semaphore1 = new TaskCompletionSource<bool>();\n    private
``` csharp\nusing System.Threading.Tasks;\n\npublic class Foo\n{\n    private TaskCompletionSource<bool> semaphore1 = new TaskCompletionSource<bool>();\n    private TaskCompletionSource<bool> semaphore2 = new TaskCompletionSource<bool>();\n\n    public Foo()\n    {\n\n    }\n\n    public void First(Action printFirst)\n    {\n        printFirst();\n        semaphore1.SetResult(true);\n    }\n\n    public void Second(Action printSecond)\n    {\n        semaphore1.Task.Wait();\n        printSecond();\n        semaphore2.SetResult(true);\n    }\n\n    public void Third(Action printThird)\n    {\n        semaphore2.Task.Wait();\n        printThird();\n    }\n}\n\n```
[]