title: How to Simplify Asynchronous Programming in F#
body: <p>I come from a C# background having used async/ await.  I am trying to find a &quot;less verbose&quot; way of programming using a library.
  ( specifically the Microsoft Playwright library for browser automation )</p>
  <pre><code>let (~~) = Async.AwaitTask
  let getLastPageNumber(page: IPage) = 
      let playwright = ~~Playwright.CreateAsync() |&gt; Async.RunSynchronously
      let browser = ~~playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions(Headless = false )) |&gt; Async.RunSynchronously
      ~~page.GotoAsync(&quot;https://go.xero.com/BankRec/BankRec.aspx?accountID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&amp;page1&quot;) |&gt; Async.RunSynchronously |&gt; ignore
      let lastPageLink = ~~page.QuerySelectorAsync(&quot;#mainPagerEnd&quot;) |&gt; Async.RunSynchronously
      if lastPageLink = null then
          //this is the last page
          1
      else
          let lastPageNumber = ~~lastPageLink.GetAttributeAsync(&quot;href&quot;) |&gt; Async.RunSynchronously
          lastPageNumber |&gt; int
  </code></pre>
  <p>I have shortened things a bit using the alias ~~ for Async.AwaitTask but it seems to be a lot of code to do something that was a lot easier in C#.</p>