title: C# synchronization between async tasks with infinite while loop?
body: <p>I have one async task running an infinite loop doing some realtime processing:</p>
  
  <pre><code>private async void RealTimeProcessingAsync()
  {
      while (true)
      {
          //....
         Tmstaus  status = await ReadStatusAsync();
         switch (status)
         {
              case Ack:
              //...
              break;
              //...
          }
          //...
      }
  }
  </code></pre>
  
  <p>And I created another async method SendWriteRqst that post command to RealTimeProcessingAsync(), should wait for status to set to defined condition and return.</p>
  
  <pre><code>public async Task&lt;WriteState&gt; SendWriteRqstAsync(TmCommand tmCmd)
  {
      //...
      await SomeCondition()//based on status value
      //...
      return wrState;
  }
  </code></pre>
  
  <p>It will works if SomeCondition() runs another while loop to polling status and return true if conditions set, but I'm looking for better solution.</p>
  
  <p>(Sorry for bad English)</p>