title: asp.net identity - SetPasswordHashAsync
body: <p>I'm trying to configure identity to work with custom provider. So far all good, I've created <code>UserStore</code>:</p>
  
  <pre><code>public class UserStore : IUserStore&lt;User&gt;, IUserPasswordStore&lt;User&gt;
  </code></pre>
  
  <p>(with all methods implemented) and UserManager:</p>
  
  <pre><code>public UserManager(IUserStore&lt;User&gt; userStore)
          : base(userStore)
      { }
  </code></pre>
  
  <p>and User is my custom entity to hold users.</p>
  
  <p>The problem is that in <code>UserStore</code> I have the following:</p>
  
  <pre><code>public async Task SetPasswordHashAsync(User user, string passwordHash)
  </code></pre>
  
  <p>From what I have understood, this is called before user is created, so all I should do here is:</p>
  
  <pre><code>public Task SetPasswordHashAsync(User user, string passwordHash)
  {
      user.PasswordHash = passwordHash;
  }
  </code></pre>
  
  <p>... but this has to return a Task and I don't see anything asynchronous to be done here.</p>
  
  <ol>
  <li>Why return type is Task for <code>SetPasswordHashAsync</code> and not just void?</li>
  <li>How should I implement <code>SetPasswordHashAsync</code>?</li>
  </ol>
  
  <p>I know I can do something like</p>
  
  <pre><code>public async Task SetPasswordHashAsync(User user, string passwordHash)
  {
      user.PasswordHash = passwordHash;
      await Task.FromResult(0);
  }
  </code></pre>
  
  <p>... but isn't this synchronous? It is weird to see all other methods decorated with <code>async</code> Task and use <code>await</code>, and this one to return <code>Task.FromResult()</code></p>
  
  <p>Anyone?</p>