Pass tasks that you want to run in parallel to Task.WhenAny
and then get result of first completed task:
var completedTask = await Task.WhenAny(
FindByNameAsync(userForLoginDto.UserName),
FindbyIdAsync(userForLoginDto.Id));
var user = await completedTask;
Note: usually you should not run a parallel search for the same data in the same database. Search by primary key should be fastest.
If you want to check whether user name is taken by another user, then just search by user name and check id of the returned user if any.
Update: If those searches are independent and you just want to run them in parallel and get all results, then use Task.WhenAll
- it will return array or resuls when all tasks are completed:
var users = await Task.WhenAll(
FindByNameAsync(userForLoginDto.UserName),
FindbyIdAsync(userForLoginDto.Id));