Functions/await.ps1


function await
{
    <#
    .SYNOPSIS
    Mimics the await keyword in C#.
 
    .DESCRIPTION
    The `await` function is used to mimic the await keyword in C#. It is used to wait for the completion of an
    asynchronous operation.
 
    .EXAMPLE
    await { $page.GotoAsync("https://www.google.com") }
    #>

    [CmdletBinding()]
    param(
        [scriptblock] $ScriptBlock
    )

    $ScriptBlock.Invoke().GetAwaiter().GetResult()
}