title: How to register an AsyncEventingBasicConsumer in F#
body: <p>I'm trying to create an asyncEventBasicConsumer in F#. 
  In order to do that I need to use <code>add_Received</code> that has the follow signature </p>
  
  <pre><code>member add_Received: 
     value: AsyncEventHandler&lt;BasicDeliverEventArgs&gt; 
         -&gt; unit
  </code></pre>
  
  <p>But I don't have idea how to create an AsyncEventHandler from
   <code>async  {}</code></p>
  
  <p>This is the concrete function</p>
  
  <pre class="lang-ml prettyprint-override"><code>let subscribe : Subscribe =
      fun factory queueName handleMessage -&gt;
          let connection = factory.CreateConnection()
          let model = connection.CreateModel()
          let consumer = AsyncEventingBasicConsumer(model)
          consumer.add_Received //?? how create a AsyncEventHandler
          model.BasicConsume(queueName, false, consumer) |&gt; ignore
          (fun () -&gt;
          model.Close()
          connection.Close())
  </code></pre>
  
  <p>And here the c# code </p>
  
  <pre class="lang-cs prettyprint-override"><code>static void Main(string[] args)
  {
      var factory = new ConnectionFactory() { DispatchConsumersAsync = true };
      const string queueName = "myqueue";
  
      using (var connection = factory.CreateConnection())
      using (var channel = connection.CreateModel())
      {
          channel.QueueDeclare(queueName, true, false, false, null);
  
          // consumer
  
          var consumer = new AsyncEventingBasicConsumer(channel);
          consumer.Received += Consumer_Received;
          channel.BasicConsume(queueName, true, consumer);
  
          // publisher
  
          var props = channel.CreateBasicProperties();
          int i = 0;
  
          while (true)
          {
              var messageBody = Encoding.UTF8.GetBytes($"Message {++i}");
              channel.BasicPublish("", queueName, props, messageBody);
              Thread.Sleep(50);
          }
      }
  }
  
  private static async Task Consumer_Received(object sender, BasicDeliverEventArgs @event)
  {
      var message = Encoding.UTF8.GetString(@event.Body);
  
      Console.WriteLine($"Begin processing {message}");
  
      await Task.Delay(250);
  
      Console.WriteLine($"End processing {message}");
  }
  
  </code></pre>