How to call async method in Autofac registration?
<p>I want to do call an <code>awaitable async</code> method during a registration like this:</p>

<pre><code>// builder variable contains Autofac ContainerBuilder
builder.Register(
    (async (context, parameters) =&gt; // need async here
        {
            var someClass = new SomeClass(context.Resolve&lt;ISomeDependency&gt;());
            await someClass.SomeAsyncInitMethod(); // need to await result
            return someClass;
        })).As&lt;ISomeClass&gt;().SingleInstance();
</code></pre>

<p><code>SomeClass</code> implements <code>ISomeClass</code> as Service.
The important part is the <code>someClass.SomeAsyncInitMethod()</code> call. This is <code>async</code>, so because of this I need to <code>await</code> it here and put the <code>async</code> keyword into the <code>Register</code> method. But now <code>Autofac</code> thinks this returns a <code>Task&lt;SomeClass&gt;</code> which is not registerable as <code>Service</code> <code>ISomeClass</code>.</p>

<p>How to achieve the above and register <code>SomeClass</code> as <code>ISomeClass</code> when awaiting the <code>async</code> init Method?</p>