title: C# Task Synchronization methods
body: <p>i have the PostRequestAsync method that process all the back-end calls.
  I do the Menu and Login call, and after that, all the other calls can be done, but not previously because the execution is not safe.
  Here there's the example of how i make a menu call, and it's similar for all the call.
  I don't think that using deadlocks is the right way in c#. Could someone suggest me the proper way to handle this situation?</p>
  
  <p>The actual code is:</p>
  
  <pre><code>public async Task&lt;T&gt; PostRequestAsync&lt;T&gt;(){
  if (servicePath.Contains("menu")) IsLoginFinished = false;
  if(!(servicePath.Contains("menu") || servicePath.Contains("login")))
   while (IsLoginFinished == false) ;
  --
  --- Other Code
  --
  if (servicePath.Contains("login")) IsLoginFinished = true; }
  </code></pre>
  
  <p>Here there's the call to the PostRequestAsync</p>
  
  <pre><code>public async Task&lt;ResponseCallModel&gt; Menu(){
  return await PHttpClient.Instance.PostRequestAsync&lt;ResponseMenuRecuperaModel&gt;(); }
  </code></pre>
  
  <p>And the call to Menu</p>
  
  <pre><code>var retrieve = await service.Menu();
  </code></pre>