title: send async azure event hub data method
body: <p>In my api (c#), i'm currently answering lots of request (15-20 in a second). Now i want to send the data to event hub for some purposes. But i dont want to delay the user for sending data to azure event hub. So i need to make async request to event hub beacuse while my app sending data to azure i dont want to get user waited for my answer. I need to send response as quick as possible, azure may last 2-3 second.</p>
  
  <p>How can i success that? 
  I ve done smth but didnt get what i want. My code:</p>
  
  <pre><code>public static async Task&lt;string&gt; SendEvents(List&lt;object&gt; messages)
  {
      string eventHubName = "rcmds";
  
      var connectionString = GetServiceBusConnectionString();
  
      CreateEventHub(eventHubName, connectionString);
  
      var eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);
  
      try
      {
          List&lt;Task&gt; tasks = new List&lt;Task&gt;();
  
          for (int i = 0; i &lt; messages.Count; i++)
          {
              var serializedMessage = JsonConvert.SerializeObject(messages[i]);
  
              EventData data = new EventData(Encoding.UTF8.GetBytes(serializedMessage));
  
              // Mesajları Event Hub a yolla
              tasks.Add(eventHubClient.SendAsync(data));
          }
  
          Task.WaitAll(tasks.ToArray());
          System.Threading.Thread.Sleep(7000);
      }
      catch (Exception ex)
      {
          new ExceptionHandler(ex, "Event Hub Library Sender - SendEvents");
      }
      finally
      {
          eventHubClient.CloseAsync().Wait();
      }
      return "";
  }
  </code></pre>
  
  <p>and i call this method like:</p>
  
  <pre><code> static async void method()
  
  
   {
              List&lt;object&gt; list = new List&lt;object&gt;();
              list.Add("dogrudur");
              await Utilities.EventHub.Sender.SendEvents(list);
          }
  </code></pre>
  
  <p>As you can see, there is "thread.sleed" code but i waited 7 seconds :/</p>