C# .NET async await return type
<p>Just hoping someone could clear up return types when using <code>async</code> and <code>await</code> in C#. I understand that you have three return types being <code>Task&lt;T&gt;</code>, <code>Task</code> and <code>void</code>.</p>

<p>From trying to learn about this I have read you should only use <code>void</code> in special circumstances (Event Handlers) and if you are changing a synchronous method to an <code>async</code> method then you should change a <code>void</code> keyword to <code>Task</code>.</p>

<p>My question is do I need a <code>Task</code> return type even though the code is completely independent and the result doesn't matter for the continuation? Say for example I use the asynchronous method to push some information to a web service.</p>

<p>I have created a small example to help explain:</p>

<pre><code>private void CallingMethod()
{
    AsyncMethod();
    AsyncTaskMethod(); // any difference between doing these? (not exc handling)

    var task = AsyncTaskMethod(); // should I do anything with this task
                                  // before I continue? Or is it simply 
                                  // just to show the user that it's async??

    // continue with unrelated code that doesnt require task or any code from above
}

private async void AsyncMethod() // is void okay?
{
    await LongRunningMethod();

    // do other stuff
}

private async Task AsyncTaskMethod() // or should it be Task?
{
    await LongRunningMethod();

    // do other stuff
}

private async Task LongRunningMethod()
{
    // do long running code
}
</code></pre>

<p>My application has a lot of methods like so:</p>

<pre><code>private void BigMethod()
{
    DoStuff();

    DoMoreStuff();

    AsyncMethod(); // is this right? Or should I have the task declaration too?

    UnrelatedStuff();
}

private async Task AsyncMethod() // should this return task?
{
    var result = await GetUserId();

    if (result == null)
        return;

    MyUserId = result;
}

private async Task&lt;int&gt; GetUserId()
{
    // do long running code
    return 1;
}
</code></pre>

<p>If it's not clear, by all means just say and I'll try to tidy it up a bit. Thanks guys.</p>

<p>EDIT:</p>

<pre><code>private void CallingMethod()
{
    AsyncMethod();
}

private async void AsyncMethod()
{
    await LongRunningMethod();
}

private async Task LongRunningMethod()
{
    await Task.Run(() =&gt;
    {
        Thread.Sleep(4000);
    });

    MessageBox.Show("Done!");
}
</code></pre>

<p>In response to the first comment, the above <code>CallingMethod()</code> does not use async/await and it happily sleeps for 4 seconds without locking up the UI thread, then pops up the message box. What's the problem?</p>