Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Binding a one-line lambda expression. Does it need to be async when calling async Task method?

$
0
0

Let's say I have an async Method:

private async Task DoSomethingAsync(int value){    await Library.SomethingAwesomeAsync(value);}

Now I have an input-control:

<input type="text" @bind="FancyProperty" @bind:after="() => DoSomethingAsync(inputValue)" />

This does not give me a warning. But I'd expect I need to write the following:

<input type="text" @bind="FancyProperty" @bind:after="async () => await DoSomethingAsync(inputValue)" />

Does anyone know why both ways seem valid?

When writing the following inside a normal C# method, I get a warning ("Because this call is not awaitet, execution of the method continues before...."):

Task task = new Task(() => DoSomethingAsync(inputValue));

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>