title: SqlCommand.ExecuteReaderAsync stops firing InfoMessage event after first SELECT statement in a stored procedure
body: <p>I have to use stored procedures for accessing data and also consume messages (like <code>PRINT 'hello'</code>) sent from the DB engine.</p>
  
  <p>When I a use <code>InfoMessage</code> event of SQL connection and fill the data into <code>DataTable</code>, everything works perfect.</p>
  
  <p>However, when I have to read data sequentially and use <code>SqlDataReader.ExecuteReaderAsync</code>, connection stops firing InfoMessage after first select statement in the stored procedure:</p>
  
  <p>C# code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using (SqlConnection con = new SqlConnection("connection-string"))
  {
      con.Open();
      con.InfoMessage += (s, e) =&gt; {
          Console.WriteLine(e.Message);
      };
  
      using (SqlCommand command = new SqlCommand("spTestMessage", con))
      {
          command.CommandType = System.Data.CommandType.StoredProcedure;
  
          SqlDataReader reader = await command.ExecuteReaderAsync();
  
          int cntr = 0;
  
          while (reader.Read())
          {
              Console.WriteLine($"Loaded row {cntr++}");
          }
  
          // reader.NextResult(); // this line forces firing rest of InfoMessage events
      }
  }
  </code></pre>
  
  <p>SQL Stored Procedure:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[spTestMessage]
  AS
  
  PRINT 'Before select 1'
  select * from MyTable
  PRINT 'After select 1'
  
  PRINT 'Before select 2'
  select * from MyTable
  PRINT 'After select 2'
  </code></pre>
  
  <p>Program output:</p>
  
  <pre><code>Before select 1
  </code></pre>
  
  <p>Why it stops working? I thing there is something wrong with Reader, because when I use <code>command.ExecuteNonQueryAsync();</code> instead of <code>command.ExecuteReaderAsync();</code>, it also works.</p>
  
  <p>I incidentally found out, that commented row <code>reader.NextResult();</code> forces the connection to flush the messages and fire remaining events. However, its a very unlucky workaround.</p>
  
  <p>Thanks for any help!</p>