title: Starting async method as Thread or as Task
body: <p>I'm new to <code>C#</code>s <code>await/async</code> and currently playing around a bit.</p>
  
  <p>In my scenario I have a simple client-object which has a <code>WebRequest</code> property. The client should send periodically alive-messages over the <code>WebRequest</code>s <code>RequestStream</code>.
  This is the constructor of the client-object:</p>
  
  <pre><code>public Client()
  {
      _webRequest = WebRequest.Create("some url");
      _webRequest.Method = "POST";
  
      IsRunning = true;
  
      // --&gt; how to start the 'async' method (see below)
  }
  </code></pre>
  
  <p>and the async alive-sender method</p>
  
  <pre><code>private async void SendAliveMessageAsync()
  {
      const string keepAliveMessage = "{\"message\": {\"type\": \"keepalive\"}}";
      var seconds = 0;
      while (IsRunning)
      {
          if (seconds % 10 == 0)
          {
              await new StreamWriter(_webRequest.GetRequestStream()).WriteLineAsync(keepAliveMessage);
          }
  
          await Task.Delay(1000);
          seconds++;
      }
  }
  </code></pre>
  
  <p>How should the method be started?</p>
  
  <blockquote>
    <p>new Thread(SendAliveMessageAsync).Start();</p>
  </blockquote>
  
  <p>or</p>
  
  <blockquote>
    <p>Task.Run(SendAliveMessageAsync); // changing the returning type to Task</p>
  </blockquote>
  
  <p>or</p>
  
  <blockquote>
    <p>await SendAliveMessageAsync(); // fails as of the constructor is not async</p>
  </blockquote>
  
  <p>My question is more about my personal understanding of <code>await/async</code> which I guess may be wrong in some points.</p>
  
  <p>The third option is throwing</p>
  
  <pre><code>The 'await' operator can only be used in a method or lambda marked with the 'async' modifier
  </code></pre>