'Wait hub to execute on method to proceed C#

I'm making an integration test and want a method to wait until "on method" is called. In C#.
Something like this:

public async Task CheckMethod(){
    var hubConnection = GetHubConnection();
    connection.On("OnMethod",async () =>{
        Log("First");
    }
    await connection.InvokeAsync("Subscribe", id);
    // Something to wait then proceed
    Log("Second");
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source