title: Async methods Explanation
body: <p>Ok so I am new to async, await and Task so I played around a bit and googled but I am not quite sure yet how it works and how it is supposed to be implemented
  So let me start by giving my code</p>
  
  <pre><code>public class MessageQuery
  {
      public byte[] Buffer { get; set; }
  }
  
  public class MessageQuery&lt;T&gt; : MessageQuery
  {
      private SocketLayer _socketLayer;
      private readonly ManualResetEvent _wait = new ManualResetEvent(false);
      public MessageQuery(SocketLayer socketLayer)
      {
          this._socketLayer = socketLayer;
      }
  
      public Task&lt;T&gt; Execute()
      {
          _wait.Reset();//Set the wait
          var task = new Task&lt;T&gt;(SendAndWait);
          task.Start();
          return task;
      }
  
      private T SendAndWait()
      {
          _socketLayer.ExecuteQuery(this);
          _wait.WaitOne();
          //Deserialize recieved bytes to T
          return default(T);
      }
  
  }
  
  public class SocketLayer
  {
      public MessageQuery&lt;T&gt; BuildTask&lt;T&gt;(/*some parameters*/)
      {
          //Build the message query from all parameters
  
          return new MessageQuery&lt;T&gt;(this);
      }
  
  
      public void ExecuteQuery(MessageQuery query)
      {
          //Using Sockets send Buffer
          //Another Thread will listen and receive buffers, with using SequenceId's it will notify the correct MessageQuery to be completed with the result
      }
  }
  
  public class GlobalAccess
  {
      readonly SocketLayer _layer = new SocketLayer();
      public Task&lt;List&lt;Client&gt;&gt; LoadedClients { get; set; }
      public Task&lt;List&lt;Client&gt;&gt; GetAllClients()
      {
          if (LoadedClients != null)
          {
              var task = _layer.BuildTask&lt;List&lt;Client&gt;&gt;();
              LoadedClients = task.Execute();
          }
          return LoadedClients;
      }
  }
  
  
  public class SomeForm
  {
      readonly GlobalAccess _access = new GlobalAccess();
  
      //Approach I am not using currently
      async void Button_whateverClickWithAsync(/*parameters*/)
      {
          var clients = await _access.GetAllClients();
          //Do whatever
      }
  
      //Approach I am using currently
      void Button_whateverClickWithoutAsync(/*parameters*/)
      {
          _access.GetAllClients().ContinueWith(HandleResult);
          //Do whatever
      }
  
      private void HandleResult(Task&lt;List&lt;Client&gt;&gt; x)
      {
          //Using Dispatcher to Do whatever
      }
  }
  </code></pre>
  
  <p>The above code is only a 'simplified' explanation of how I designed my classes, there is more to it than just this but it should give you an Idea.
  Now I am currently using this in wpf &amp; Xamarin and it works well but in Xamarin I started to use Task and not Thread because PCL has only Task in, this gave me and Idea to rewrite parts of code using the pattern above (which is partially completed) BUT I do not understand the async/await completely, using the above code which will be the better approach to use, or is there a better approach to take</p>