title: Task await does not return the result
body: <p>I am trying to write a function which uses Task and TaskCompletion.</p>
  
  <p>My problem is that after login, the result is not returned. I used similar code before and it was working. I do not know what causes for this situation.</p>
  
  <pre><code>public async Task&lt;byte[]&gt; Sign(byte[] documentContent)
  {
      var service = new SignServiceWrapper("https://example.com?wsdl");
      var loginResult = await Task.Run(() =&gt; service.Login(loginRequest));
  
      //....
  }
  </code></pre>
  
  <p>and my SignServiceWrapper class</p>
  
  <pre><code>public class SignServiceWrapper
  {
      private static string _webServiceUrl;
      private  BrokerClientClient client;
  
      public SignServiceWrapper(string webServiceUrl)
      {
          _webServiceUrl = webServiceUrl;
      }
  
      public Task&lt;loginResponse&gt; Login(loginRequest request)
      {
          var tcs = new TaskCompletionSource&lt;loginResponse&gt;();
  
          ClientGenerator.WebServiceUrl = _webServiceUrl;
  
          ClientGenerator.InitializeService(); 
          client = ClientGenerator.ServiceClient;   
  
          client.loginCompleted += (sender, loginResult) =&gt;
          {
              if (loginResult.Error != null)
                  tcs.SetException(loginResult.Error);
              else
                  tcs.TrySetResult(loginResult.Result);
          };    
  
          client.loginAsync(request);                
  
          return tcs.Task;
      }
  
      // ...
  }
  </code></pre>
  
  <p>If I call my login function like that it works</p>
  
  <pre><code>var loginResult = Task.Run(() =&gt; service.Login(loginRequest));
  loginResult.Wait();
  </code></pre>
  
  <p>I know that there is kind of a deadlock but I don't know how to solve this here and which object.</p>