I have an async method:
public async Task<UserLoginExResult> LoginExAsync(CustomTable exRequest, string language, bool throwEx = true) { UserLoginExResult result = await UserService.LoginExAsync(UserGroup, language, TimezoneOffset, GetDeviceInfo(), GetLoginProperties(), exRequest); ProcessLoginResult(result, false, throwEx); return result; }
And an overload:
public Task<UserLoginExResult> LoginExAsync(CustomTable exRequest, bool throwEx = true) { return LoginExAsync(exRequest, Language.ID, throwEx); }
I'm not sure if I should mark the overloaded one (the one with fewer parameters) as async
and use await
? I guess I should not but can you tell me what whould happen if I would do that? I'm quite lost in here and not really sure what Task
it would wait for? Would it create an extra Task
or await
doesn't create a new Task
?
No, there's little benefit in using an async method when it's just going to wrap and unwrap an existing one. It's fine to just have a "normal" method here, delegating to the "real" async method.
(They're not quite the same - for example, if the UserService.LoginExAsync
method throws an exception rather than returning a failed task, the async/await version will just return a failed task, whereas the other version will also throw immediately.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With