private async Task<T> LoadForm(WebControlAsync browser, Uri url)
{ ... }
var forms = await await _dispatcher.InvokeAsync(async () => await LoadForm(browser, form.Url));
I don't understand why I have to use two await
's here to get T
in forms
? So it looks as InvokeAsync
returns Task<Task<T>>
. But when I invoke synchronous method like this:
var forms = await _dispatcher.InvokeAsync(() => FillForm(forms, url));
it requires only single await
. So the cause seems to be async lambda. I understand that if I write it this way:
var forms = await await _dispatcher.InvokeAsync(() => LoadForm(browser, form.Url));
then the return type of LoadForm
is Task<T>
and InvokeAsync
returns Task<lambda return type>
so it indeed would be Task<Task<T>>
. But when a Task
method is await
'ed, isn't it "unwraps" the actual return type from Task
? So if I write:
var forms = await LoadForm(browser, form.Url);
forms
would be T
, not Task<T>
. Why the same isn't happen in async lambda?