METHOD

EventCallback<TValue>.InvokeAsync

Invokes the typed callback and returns a task representing its completion. Await it rather than using async void. Component dispatch and rendering depend on the associated receiver and renderer. Requires the ASP.NET Core shared framework or matching reference assemblies.

Formal Syntax & Structure

csharp syntaxcsharp
await callback.InvokeAsync(value)

Working Example

Example Snippetcsharp
using System;using System.Linq;using System.Threading;using Microsoft.AspNetCore.Components;using Microsoft.AspNetCore.Components.Forms;using Microsoft.AspNetCore.SignalR;int seen=0; var callback=EventCallback.Factory.Create<int>(new object(),(Action<int>)(n=>seen=n)); await callback.InvokeAsync(7); Console.WriteLine(seen); // 7
C# & .NET Reference