0

I need to assign async Task method to a multicastdelegate parameter as follows.

protected async Task GridRowSelect(Employee emp)
{
    await Service.SetRowSelect(emp.Id);
}

gridSettings.RowSelect = new EventCallback<Employee>(this, (Action<Employee>)GridRowSelect);

But it gives an error.

'Task GridRowSelect(Employee) has the wrong return type'

If I change async Task to async void this is working. But is that the correct way?

Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
AnC Dev
  • 141
  • 12

1 Answers1

1

Yes, async void is the correct way. The async void is intended specifically for making asynchronous event handlers possible. That's the whole reason for its existence. So using it for handling the RowSelect event is OK.

Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104